workbox-window.prod.es5-1e93291f-1763717014417.js 5.7 KB

1
  1. try{self["workbox:window:7.3.0"]&&_()}catch(n){}function b(n,r){return new Promise(function(t){var o=new MessageChannel;o.port1.onmessage=function(f){t(f.data)},n.postMessage(r,[o.port2])})}function P(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,o=Array(r);t<r;t++)o[t]=n[t];return o}function E(n,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,W(o.key),o)}}function S(n,r){var t=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=function(f,s){if(f){if(typeof f=="string")return P(f,s);var a={}.toString.call(f).slice(8,-1);return a==="Object"&&f.constructor&&(a=f.constructor.name),a==="Map"||a==="Set"?Array.from(f):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?P(f,s):void 0}}(n))||r&&n&&typeof n.length=="number"){t&&(n=t);var o=0;return function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(n,r){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},w(n,r)}function W(n){var r=function(t,o){if(typeof t!="object"||!t)return t;var f=t[Symbol.toPrimitive];if(f!==void 0){var s=f.call(t,o||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(t)}(n,"string");return typeof r=="symbol"?r:r+""}try{self["workbox:core:7.3.0"]&&_()}catch(n){}var m=function(){var n=this;this.promise=new Promise(function(r,t){n.resolve=r,n.reject=t})};function y(n,r){var t=location.href;return new URL(n,t).href===new URL(r,t).href}var d=function(n,r){this.type=n,Object.assign(this,r)};function l(n,r,t){return t?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n)}function k(){}var L={type:"SKIP_WAITING"};function j(n,r){if(!r)return n&&n.then?n.then(k):Promise.resolve()}var O=function(n){function r(s,a){var e,i;return a===void 0&&(a={}),(e=n.call(this)||this).nn={},e.tn=0,e.rn=new m,e.en=new m,e.on=new m,e.un=0,e.an=new Set,e.cn=function(){var u=e.fn,c=u.installing;e.tn>0||!y(c.scriptURL,e.sn.toString())||performance.now()>e.un+6e4?(e.vn=c,u.removeEventListener("updatefound",e.cn)):(e.hn=c,e.an.add(c),e.rn.resolve(c)),++e.tn,c.addEventListener("statechange",e.ln)},e.ln=function(u){var c=e.fn,v=u.target,h=v.state,p=v===e.vn,g={sw:v,isExternal:p,originalEvent:u};!p&&e.mn&&(g.isUpdate=!0),e.dispatchEvent(new d(h,g)),h==="installed"?e.wn=self.setTimeout(function(){h==="installed"&&c.waiting===v&&e.dispatchEvent(new d("waiting",g))},200):h==="activating"&&(clearTimeout(e.wn),p||e.en.resolve(v))},e.yn=function(u){var c=e.hn,v=c!==navigator.serviceWorker.controller;e.dispatchEvent(new d("controlling",{isExternal:v,originalEvent:u,sw:c,isUpdate:e.mn})),v||e.on.resolve(c)},e.gn=(i=function(u){var c=u.data,v=u.ports,h=u.source;return l(e.getSW(),function(){e.an.has(h)&&e.dispatchEvent(new d("message",{data:c,originalEvent:u,ports:v,sw:h}))})},function(){for(var u=[],c=0;c<arguments.length;c++)u[c]=arguments[c];try{return Promise.resolve(i.apply(this,u))}catch(v){return Promise.reject(v)}}),e.sn=s,e.nn=a,navigator.serviceWorker.addEventListener("message",e.gn),e}var t,o;o=n,(t=r).prototype=Object.create(o.prototype),t.prototype.constructor=t,w(t,o);var f=r.prototype;return f.register=function(s){var a=(s===void 0?{}:s).immediate,e=a!==void 0&&a;try{var i=this;return l(function(u,c){var v=u();return v&&v.then?v.then(c):c(v)}(function(){if(!e&&document.readyState!=="complete")return j(new Promise(function(u){return window.addEventListener("load",u)}))},function(){return i.mn=!!navigator.serviceWorker.controller,i.dn=i.pn(),l(i.bn(),function(u){i.fn=u,i.dn&&(i.hn=i.dn,i.en.resolve(i.dn),i.on.resolve(i.dn),i.dn.addEventListener("statechange",i.ln,{once:!0}));var c=i.fn.waiting;return c&&y(c.scriptURL,i.sn.toString())&&(i.hn=c,Promise.resolve().then(function(){i.dispatchEvent(new d("waiting",{sw:c,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.yn),i.fn})}))}catch(u){return Promise.reject(u)}},f.update=function(){try{return this.fn?l(j(this.fn.update())):l()}catch(s){return Promise.reject(s)}},f.getSW=function(){return this.hn!==void 0?Promise.resolve(this.hn):this.rn.promise},f.messageSW=function(s){try{return l(this.getSW(),function(a){return b(a,s)})}catch(a){return Promise.reject(a)}},f.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&b(this.fn.waiting,L)},f.pn=function(){var s=navigator.serviceWorker.controller;return s&&y(s.scriptURL,this.sn.toString())?s:void 0},f.bn=function(){try{var s=this;return l(function(a,e){try{var i=a()}catch(u){return e(u)}return i&&i.then?i.then(void 0,e):i}(function(){return l(navigator.serviceWorker.register(s.sn,s.nn),function(a){return s.un=performance.now(),a})},function(a){throw a}))}catch(a){return Promise.reject(a)}},function(s,a,e){return a&&E(s.prototype,a),e&&E(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}(r,[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}])}(function(){function n(){this.Pn=new Map}var r=n.prototype;return r.addEventListener=function(t,o){this.jn(t).add(o)},r.removeEventListener=function(t,o){this.jn(t).delete(o)},r.dispatchEvent=function(t){t.target=this;for(var o,f=S(this.jn(t.type));!(o=f()).done;)(0,o.value)(t)},r.jn=function(t){return this.Pn.has(t)||this.Pn.set(t,new Set),this.Pn.get(t)},n}());export{O as Workbox,d as WorkboxEvent,b as messageSW};