Commit beb46482 by 万亚飞

fix bug

parent de5d7abd
......@@ -163,12 +163,12 @@ module.exports = {
//include: ['app']
}),
new webpack.NamedModulesPlugin(),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
importWorkboxFrom: 'local',
include: [/\.js$/, /\.css$/, /\.html$/, /\.jpg/, /\.jpeg/, /\.svg/, /\.webp/, /\.png/]
}),
// new WorkboxPlugin.GenerateSW({
// clientsClaim: true,
// skipWaiting: true,
// importWorkboxFrom: 'local',
// include: [/\.js$/, /\.css$/, /\.html$/, /\.jpg/, /\.jpeg/, /\.svg/, /\.webp/, /\.png/]
// }),
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css'
}),
......
.am-tabs{height:10rem}.am-tabs,.am-tabs .am-tabs-content-wrap,.am-tabs .am-tabs-tab-bar-wrap{width:100%}.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap{width:100%;overflow:hidden}.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap .slide-container,.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap .slide-container img{width:100%}.list{width:100%;list-style:none;height:1.5rem;background-color:#f5f5f5}.list,.list li{display:-webkit-flex;display:-ms-flexbox;display:flex}.list li{width:25%;height:100%;font-size:.8rem;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.list .item1{color:salmon}.list .item2{color:#f4a460}.list .item3{color:red}.list .item4{color:#87ceeb}.main-gif{width:100%;height:5rem;-webkit-transform:translateZ(0);transform:translateZ(0)}.main-gif img{width:100%;height:100%}.my-carousels .slider-slide{text-align:center;height:1rem!important;color:salmon}.test,.test .slider-frame{height:1rem!important}.test .slider-frame .slider-list{height:100%!important}.test .slider-frame .slider-list .slider-slide{height:1rem!important}a,article,aside,b,body,button,dd,div,dl,dt,figcaption,figure,footer,h1,h2,h3,h4,h5,h6,header,i,input,li,nav,p,section,select,textarea,ul{padding:0;margin:0;list-style:none;font-style:normal;text-decoration:none;border:none;font-weight:400}a:hover,article:hover,aside:hover,b:hover,body:hover,button:hover,dd:hover,div:hover,dl:hover,dt:hover,figcaption:hover,figure:hover,footer:hover,h1:hover,h2:hover,h3:hover,h4:hover,h5:hover,h6:hover,header:hover,i:hover,input:hover,li:hover,nav:hover,p:hover,section:hover,select:hover,textarea:hover,ul:hover{outline:none}body{margin:0 auto;font-size:12px;line-height:1.4;font-family:Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Arial,sans-serif;background-color:#fff;color:#000;-webkit-overflow-scrolling:touch;-webkit-font-smoothing:subpixel-antialiased}.page-container{height:100%}*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-touch-callout:none;box-sizing:border-box}.break{word-wrap:break-word;word-break:break-all}a{text-decoration:none;color:#3d9eff}a,em{display:inline-block}em{font-style:normal}img{border:none;vertical-align:top}input,textarea{border:none;outline:none;-webkit-appearance:none}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}input::-moz-placeholder,textarea::-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::placeholder,textarea::placeholder{color:#999}.abs{position:absolute}.rel{position:relative}.fix{position:fixed}.db{display:block}.dn{display:none}.di{display:inline}.dib{display:inline-block}.df{display:-webkit-flex;display:-ms-flexbox;display:-moz-flex;display:flex}.vh{visibility:hidden}.fx1{-webkit-flex:1;-moz-flex:1;-ms-flex:1;flex:1}.fx2{-webkit-flex:2;-moz-flex:2;-ms-flex:2;flex:2}.fx3{-webkit-flex:3;-moz-flex:3;-ms-flex:3;flex:3}.fx4{-webkit-flex:4;-moz-flex:4;-ms-flex:4;flex:4}.fx5{-webkit-flex:5;-moz-flex:5;-ms-flex:5;flex:5}.fx6{-webkit-flex:6;-moz-flex:6;-ms-flex:6;flex:6}.fx7{-webkit-flex:7;-moz-flex:7;-ms-flex:7;flex:7}.fx8{-webkit-flex:8;-moz-flex:8;-ms-flex:8;flex:8}.fx9{-webkit-flex:9;-moz-flex:9;-ms-flex:9;flex:9}.fx10{-webkit-flex:10;-moz-flex:10;-ms-flex:10;flex:10}.jcs{-moz-justify-content:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start}.jcc{-moz-justify-content:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.jce{-moz-justify-content:flex-end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end}.jcb{-webkit-justify-content:space-between;-moz-justify-content:space-between;-ms-justify-content:space-between;-o-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-flex-pack:space-between;flex-pack:space-between}.jca{-webkit-justify-content:space-around;-moz-justify-content:space-around;-ms-justify-content:space-around;-o-justify-content:space-around;-ms-flex-pack:distribute;justify-content:space-around;-webkit-flex-pack:distribute;flex-pack:distribute}.fxdc{-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;-o-flex-direction:column;flex-direction:column}.fxdcr{-webkit-flex-direction:column-reverse;-moz-flex-direction:column-reverse;-ms-flex-direction:column-reverse;-o-flex-direction:column-reverse;flex-direction:column-reverse}.fxdr{-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row}.fxdrr{-webkit-flex-direction:row-reverse;-moz-flex-direction:row-reverse;-ms-flex-direction:row-reverse;-o-flex-direction:row-reverse;flex-direction:row-reverse}.fxww{-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.fxwn{-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.fxwr{-webkit-flex-wrap:wrap-reverse;-ms-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse}.ais{-moz-align-items:flex-start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start}.aic{-moz-align-items:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.aie{-moz-align-items:flex-end;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end}.aisr{-moz-align-items:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch}.acs{-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}.acc{-webkit-align-content:center;-ms-flex-line-pack:center;align-content:center}.ace{-webkit-align-content:flex-end;-ms-flex-line-pack:end;align-content:flex-end}.acb{-webkit-align-content:space-between;-ms-flex-line-pack:justify;align-content:space-between}.aca{-webkit-align-content:space-around;-ms-flex-line-pack:distribute;align-content:space-around}.od1{-webkit-order:1;-ms-flex-order:1;order:1}.od2{-webkit-order:2;-ms-flex-order:2;order:2}.od3{-webkit-order:3;-ms-flex-order:3;order:3}.op1{opacity:.1}.op2{opacity:.2}.op3{opacity:.3}.op4{opacity:.4}.op5{opacity:.5}.op6{opacity:.6}.op7{opacity:.7}.op8{opacity:.8}.op9{opacity:.9}.ls1-{letter-spacing:-1px}.ls2-{letter-spacing:-2px}.ls3-{letter-spacing:-3px}.ls1{letter-spacing:1px}.ls2{letter-spacing:2px}.ls3{letter-spacing:3px}.fz12{font-size:12px}.fz14{font-size:14px}.fz15{font-size:15px}.fz16{font-size:16px}.fz17{font-size:17px}.fz18{font-size:18px}.fz20{font-size:20px}.fz22{font-size:22px}.fz24{font-size:24px}.fz30{font-size:30px}.mt5{margin-top:5px}.mt10{margin-top:10px}.mt20{margin-top:20px}.mt30{margin-top:30px}.mb5{margin-bottom:5px}.mb10{margin-bottom:10px}.mr5{margin-right:5px}.c1{color:#111}.c2{color:#222}.c3{color:#333}.c4{color:#444}.c5{color:#555}.c6{color:#666}.c7{color:#777}.c8{color:#888}.c9{color:#999}.white{color:#fff}.black{color:#000}.c-b3{color:#b3b3b3}.c-red{color:#ff5040}.c-24{color:#242424}.c-green{color:#0c8}.tac{text-align:center}.tar{text-align:right}.tal{text-align:left}.taj{text-align:justify}.fl{float:left}.fr{float:right}.pt0{padding-top:0}.pt10{padding-top:10px}.p20{padding:20px}.pt20{padding-top:20px}.pt40{padding-top:40px}.pb20{padding-bottom:20px}.pb40{padding-bottom:40px}.vam{vertical-align:middle}.vat{vertical-align:top}.vab{vertical-align:bottom}.n{font-weight:400;font-style:normal}.b{font-weight:700}.f100{font-weight:100}.i{font-style:italic}.ovh{overflow:hidden}.ovs{overflow:scroll}.ff{font-family:PingFang-SC-Medium}.fs{font-style:normal}.fcolor{color:#ff5b05}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.clear{zoom:1}.clear:after{content:"";display:block;clear:both}.line1{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.line2{-webkit-line-clamp:2}.line2,.line3{display:-webkit-box;overflow:hidden}.line3{-webkit-line-clamp:3}.cup{cursor:pointer}.mauto{margin:0 auto}.bg-white{background:#fff}.bg-black{background:#000}.btn:active,btn.active{background-image:none;outline:0;box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn{display:inline-block;padding:6px 12px;cursor:pointer;border:1px solid transparent;border-radius:4px}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:active:hover{color:#333;background-color:#d4d4d4;border-color:#8c8c8c}.btn-default:hover{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-primary{color:#fff;background-color:#3190e8;border-color:#338de0}.btn-primary:hover{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary:active:hover{color:#fff;background-color:#204d74;border-color:#122b40}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:active:hover{color:#fff;background-color:#378037;border-color:#8c8c8c}.btn-success:hover{color:#fff;background-color:#449d44;border-color:#adadad}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:active:hover{color:#fff;background-color:#ac2925;border-color:#761c19}.btn-danger:hover{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-block{width:100%;display:block}.box-c{padding-left:15px;padding-right:15px}.yui-cells{background-color:#fff;line-height:1.41176471;font-size:16px;overflow:hidden;position:relative}.yui-cell{padding:15px;position:relative;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.yui-cell__bd{-webkit-flex:1;-ms-flex:1;flex:1}.yui-cell_access .yui-cell__ft{padding-right:16px;position:relative}.yui-cell__ft{text-align:right;color:rgba(0,0,0,.5)}.train-warp .am-list-item .am-list-line .am-list-extra:after,.yui-cell_access .yui-cell__ft:after{content:" ";display:inline-block;height:6px;width:6px;border-color:#242424;border-style:solid;border-width:2px 2px 0 0;-webkit-transform:matrix(.71,.71,-.71,.71,0,0);-ms-transform:matrix(.71,.71,-.71,.71,0,0);transform:matrix(.71,.71,-.71,.71,0,0);position:absolute;top:50%;margin-top:-5px;right:0}.yui-cell:after{content:" ";position:absolute;bottom:0;height:1px;border-top:1px solid #e0e0e0;color:#e0e0e0;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5);left:15px;right:15px;z-index:2}.yui-cell:first-child:before{display:none}.yui-textarea{border:1px solid #e0e0e0;display:block;resize:none;width:100%;color:inherit;font-size:1em;line-height:inherit;outline:0;padding:10px;border-radius:4px}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#242424;color:#b3b3b3}input::-moz-placeholder,textarea::-moz-placeholder{color:#242424;color:#b3b3b3}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#242424;color:#b3b3b3}input::placeholder,textarea::placeholder{color:#242424;color:#b3b3b3}.bg-yellow{background:#fff5dd}.orange{color:#ff8f00}.blue{color:#1da1f2}.y-dialog-wrap{position:fixed;top:0;bottom:0;left:0;right:0;z-index:1001}.y-dialog-wrap .y-dialog{position:absolute;padding-top:50px;padding-bottom:30px;z-index:1002;left:50%;top:50%;width:80%;-ms-transform:translate(-50%,-60%);transform:translate(-50%,-60%);-webkit-transform:translate(-50%,-60%);background-color:#fff;border-radius:8px;font-size:14px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1)}.y-dialog-wrap .y-dialog .y-dialog-header{position:absolute;top:0;left:0;right:0;height:50px;line-height:50px;text-align:center}.y-dialog-wrap .y-dialog .y-dialog-header h2{font-size:16px}.y-dialog-wrap .y-dialog .y-dialog-content{overflow:auto;-webkit-overflow-scrolling:touch;height:100%;width:100%}.y-dialog-wrap .y-dialog .y-dialog-btn{width:100%;padding-top:30px}.y-dialog-wrap .y-dialog .y-dialog-btn .am-button{width:100%;border-radius:25px}.y-dialog-wrap .y-dialog .y-dialog-close{position:absolute;bottom:-50px;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.y-dialog-wrap.hide{display:none}.y-modal{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000}[class*=" y-icon"],[class^=y-icon]{display:inline-block;vertical-align:middle;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;background-size:contain;background-position:0 0;background-repeat:no-repeat}.y-icon-close-border{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAC3UExURUdwTP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3XVmpgAAAA8dFJOUwCA/aulA4NX/A9DI5zr52ExDMQByB5x5kU76Y7YYiYCuHM61SDcNvnsEwYz38uNNbJTfhXv0n9chAixXV7MnDwAAAH6SURBVFjDrVfZloIwDA1aEAR3VFTEfQEBBXfl/79rRmeckQIVjHnQc5reS9uktwlAgm09nzj2crFY2g7xvS1kspW7321O1/nUtCxzOr+eNru9u0qLro0ms8OaDw/y68NsMqqlgEtciYzjXWNS4qRX+EpZkZO9slKuMOHNulplf6Cq1pvJ3k671Xi1xEar3Uny9btamkPWuv3Y8UFPN9KFydB7gxj8ZSilDbQ0vEQZekM+faLxw15k/7qUJVUlnTqHTtfIluxGNxSLZluDjKa1n/Oh3oLM1qo/5a/ayE7QUP+yWipX4Q2rlh/nzinwlinc7/0vye8RyKUffRgRyn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ORK5CYII=);width:15px;height:15px}.am-toast-notice-content .am-toast-text{min-width:100px}.am-modal{margin-bottom:60px}.am-image-picker-list{padding:9px 0}.button-primary{background:#1da1f2;border-radius:20px;color:#fff;padding:10px 20px}.am-button{height:45px;line-height:45px}.am-list-item .am-list-line .am-list-extra,.deposit-user .my-list .am-list-item .am-list-line .am-list-content{padding:0 20px}.am-modal-footer .am-modal-button-group-h .am-modal-button{color:#1da1f2}.navBarWrap .am-navbar{background:#494751}html:not([data-scale]) .am-list-body:after,html:not([data-scale]) .am-list-body:before{width:0}.am-list-item .am-list-line .am-list-content{font-size:16px}.am-list-item .am-list-line .am-list-extra{color:#b3b3b3;font-size:14px}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:2dppx){html:not([data-scale]) .am-list-body div:not(:last-child) .am-list-line:after{right:15px;width:inherit}}.photo-wrap{position:relative}.photo-wrap .pswp-thumbnails{position:absolute;z-index:-1;top:0;width:100%;padding:9px 8px 0;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.photo-wrap .pswp-thumbnails .pswp-thumbnail{-webkit-flex:1;-ms-flex:1;flex:1;height:78px;overflow:hidden;margin-right:5px;opacity:0}.pswp__top-bar .pswp__button:not(:first-of-type){display:none}.bottom-operate{position:fixed;bottom:0;left:0;right:0;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center;padding:10px 15px;background-color:#fff;box-shadow:0 -2px 4px 0 rgba(0,0,0,.04)}.bottom-operate .am-button{width:100%;border-radius:30px}.train-warp{padding-bottom:64px}.train-warp .train-list{height:100%;background-color:#f0f0f0;overflow:hidden}.train-warp .train-list .train-item{background-color:#fff;margin-bottom:14px;position:relative}.train-warp .train-list .train-item .y-icon-collate{position:absolute;right:16px;top:0}.train-warp .train-list .train-item .item-head{color:#999;padding-top:10px;padding-bottom:10px}.train-warp .train-list .train-item .item-body{background-color:#f9f9f9;padding-top:15px;padding-bottom:15px}.train-warp .train-list .train-item .item-body .train-head{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;width:70px;height:70px;overflow:hidden;background-position:50%;background-repeat:no-repeat;background-size:contain;border:1px solid #e0e0e0;margin-right:10px}.train-warp .train-list .train-item .item-body .body-con{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;text-align:left;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.train-warp .train-list .train-item .item-operate{padding-top:8px;padding-bottom:8px;text-align:right}.train-warp .train-list .train-item .item-operate .o-btn{display:inline-block;padding:5px 22px;font-size:13px;border:1px solid #999;margin-left:10px;border-radius:20px}.train-warp .train-list .train-item .item-operate .o-btn.disabled{color:#bfbfbf;border:1px solid #bfbfbf}.train-warp .add-train{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-120%);-ms-transform:translate(-50%,-120%);transform:translate(-50%,-120%);width:205px;height:55px;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border-radius:30px;color:#fff;background-color:#1da1f2;font-size:17px}.train-warp .add-train .y-icon-add{width:17px;height:17px;margin-right:8px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiBAMAAADIaRbxAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAPUExURUdwTP///////////////xPgMRoAAAAEdFJOUwDmiAYExX3+AAAAQklEQVQoz2NggAAjQWUGVKDi4oQmIuLiiCbi4uIylEWMRFyQgaMy0NOowIlBBE3EEYsIpi5Mk4dHiOFMCZipBZGiAI8nLn1hShW3AAAAAElFTkSuQmCC)}.nav-bar{position:relative;height:42px;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;position:fixed;top:0;z-index:10;width:100%;background:#fff}.nav-bar .item-bar{-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;font-size:13px;color:#666;height:42px;line-height:42px;text-align:center}.nav-bar .item-bar:after{position:absolute;content:" ";bottom:0;left:0;right:0;border-bottom:1px solid #f0f0f0;-webkit-transform:translateY(.5);-ms-transform:translateY(.5);transform:translateY(.5)}.nav-bar .item-bar span{position:relative;display:inline-block;height:100%}.nav-bar .item-bar.active{color:#242424;font-size:15px;font-weight:700}.nav-bar .item-bar.active span:after{content:" ";position:absolute;bottom:1px;left:0;width:100%;height:4px;background:#1da1f2;border-top-left-radius:3px;border-top-right-radius:3px}.job-list-wrap{padding-top:42px}.swiper-box{height:100%}.swiper-box .swiper-item{height:100%;display:none}.swiper-box .swiper-item.active{display:block}#__next .am-list-item .am-list-line{padding-top:10px;padding-bottom:10px}#__next .am-list-item .am-list-line .am-list-extra:after{right:15px}.am-list-content{font-weight:700;font-size:16px}.tip-right{position:absolute;color:#1da1f2;right:0;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.dialog-intro{padding-left:30px;padding-right:30px;background-size:contain;background-repeat:no-repeat;background-image:url(/img/safe-bg@2x.639ee009.png)}.dialog-intro .title{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAwCAMAAAAICtykAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURUdwTCQkJCgoKCYmJiUlJSYmJiUlJSQkJCQkJDMzMyUlJSQkJCQkJCQkJCQkJCYmJiUlJSoqKiQkJCQkJCUlJSQkJCUlJSQkJCQkJCQkJP///yQkJCQkJCoqKioqKikpKSQkJCQkJCQkJCQkJCQkJCQkJC4uLigoKCQkJDg4OC4uLiUlJS4uLiQkJCUlJVVVVSUlJSQkJDMzMyQkJD8/PycnJykpKSQkJCQkJCQkJCQkJCQkJH9/fyUlJSUlJSQkJCQkJCQkJCYmJiUlJSQkJCUlJScnJyQkJCQkJCQkJCUlJSQkJD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WZy1sVcDTbPgL+pE9CbutX9S7TbRvjPIiRYwtMjb1hpvth9/UZU9BZtpRDfBxriHRnoZzTVDxbtRVHUaEENB/ehQoC/AkJACABCQAgAQkAIAEJACPBrHnMpf8Vd8IxiAAAAAElFTkSuQmCC) 0 0 no-repeat;background-size:contain;width:200px;height:24px;margin-bottom:16px}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
.am-tabs{height:10rem}.am-tabs,.am-tabs .am-tabs-content-wrap,.am-tabs .am-tabs-tab-bar-wrap{width:100%}.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap{width:100%;overflow:hidden}.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap .slide-container,.am-tabs .am-tabs-content-wrap .am-tabs-pane-wrap .slide-container img{width:100%}.list{width:100%;list-style:none;height:1.5rem;background-color:#f5f5f5}.list,.list li{display:-webkit-flex;display:-ms-flexbox;display:flex}.list li{width:25%;height:100%;font-size:.8rem;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.list .item1{color:salmon}.list .item2{color:#f4a460}.list .item3{color:red}.list .item4{color:#87ceeb}.main-gif{width:100%;height:5rem;-webkit-transform:translateZ(0);transform:translateZ(0)}.main-gif img{width:100%;height:100%}.my-carousels .slider-slide{text-align:center;height:1rem!important;color:salmon}.test,.test .slider-frame{height:1rem!important}.test .slider-frame .slider-list{height:100%!important}.test .slider-frame .slider-list .slider-slide{height:1rem!important}.ellipsis1{white-space:nowrap}.ellipsis1,.ellipsis2{overflow:hidden;text-overflow:ellipsis;word-break:break-word}.ellipsis2{display:-webkit-box;-webkit-line-clamp:2}a,article,aside,b,body,button,dd,div,dl,dt,figcaption,figure,footer,h1,h2,h3,h4,h5,h6,header,i,input,li,nav,p,section,select,textarea,ul{padding:0;margin:0;list-style:none;font-style:normal;text-decoration:none;border:none;font-weight:400}a:hover,article:hover,aside:hover,b:hover,body:hover,button:hover,dd:hover,div:hover,dl:hover,dt:hover,figcaption:hover,figure:hover,footer:hover,h1:hover,h2:hover,h3:hover,h4:hover,h5:hover,h6:hover,header:hover,i:hover,input:hover,li:hover,nav:hover,p:hover,section:hover,select:hover,textarea:hover,ul:hover{outline:none}body{margin:0 auto;font-size:12px;line-height:1.4;font-family:Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Arial,sans-serif;background-color:#fff;color:#000;-webkit-overflow-scrolling:touch;-webkit-font-smoothing:subpixel-antialiased}.page-container{height:100%}*{-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-touch-callout:none;box-sizing:border-box}.break{word-wrap:break-word;word-break:break-all}a{text-decoration:none;color:#3d9eff}a,em{display:inline-block}em{font-style:normal}img{border:none;vertical-align:top}input,textarea{border:none;outline:none;-webkit-appearance:none}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}input::-moz-placeholder,textarea::-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::placeholder,textarea::placeholder{color:#999}.abs{position:absolute}.rel{position:relative}.fix{position:fixed}.db{display:block}.dn{display:none}.di{display:inline}.dib{display:inline-block}.df{display:-webkit-flex;display:-ms-flexbox;display:-moz-flex;display:flex}.vh{visibility:hidden}.fx1{-webkit-flex:1;-moz-flex:1;-ms-flex:1;flex:1}.fx2{-webkit-flex:2;-moz-flex:2;-ms-flex:2;flex:2}.fx3{-webkit-flex:3;-moz-flex:3;-ms-flex:3;flex:3}.fx4{-webkit-flex:4;-moz-flex:4;-ms-flex:4;flex:4}.fx5{-webkit-flex:5;-moz-flex:5;-ms-flex:5;flex:5}.fx6{-webkit-flex:6;-moz-flex:6;-ms-flex:6;flex:6}.fx7{-webkit-flex:7;-moz-flex:7;-ms-flex:7;flex:7}.fx8{-webkit-flex:8;-moz-flex:8;-ms-flex:8;flex:8}.fx9{-webkit-flex:9;-moz-flex:9;-ms-flex:9;flex:9}.fx10{-webkit-flex:10;-moz-flex:10;-ms-flex:10;flex:10}.jcs{-moz-justify-content:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start}.jcc{-moz-justify-content:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.jce{-moz-justify-content:flex-end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end}.jcb{-webkit-justify-content:space-between;-moz-justify-content:space-between;-ms-justify-content:space-between;-o-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-flex-pack:space-between;flex-pack:space-between}.jca{-webkit-justify-content:space-around;-moz-justify-content:space-around;-ms-justify-content:space-around;-o-justify-content:space-around;-ms-flex-pack:distribute;justify-content:space-around;-webkit-flex-pack:distribute;flex-pack:distribute}.fxdc{-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;-o-flex-direction:column;flex-direction:column}.fxdcr{-webkit-flex-direction:column-reverse;-moz-flex-direction:column-reverse;-ms-flex-direction:column-reverse;-o-flex-direction:column-reverse;flex-direction:column-reverse}.fxdr{-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row}.fxdrr{-webkit-flex-direction:row-reverse;-moz-flex-direction:row-reverse;-ms-flex-direction:row-reverse;-o-flex-direction:row-reverse;flex-direction:row-reverse}.fxww{-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.fxwn{-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.fxwr{-webkit-flex-wrap:wrap-reverse;-ms-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse}.ais{-moz-align-items:flex-start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start}.aic{-moz-align-items:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.aie{-moz-align-items:flex-end;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end}.aisr{-moz-align-items:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch}.acs{-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}.acc{-webkit-align-content:center;-ms-flex-line-pack:center;align-content:center}.ace{-webkit-align-content:flex-end;-ms-flex-line-pack:end;align-content:flex-end}.acb{-webkit-align-content:space-between;-ms-flex-line-pack:justify;align-content:space-between}.aca{-webkit-align-content:space-around;-ms-flex-line-pack:distribute;align-content:space-around}.od1{-webkit-order:1;-ms-flex-order:1;order:1}.od2{-webkit-order:2;-ms-flex-order:2;order:2}.od3{-webkit-order:3;-ms-flex-order:3;order:3}.op1{opacity:.1}.op2{opacity:.2}.op3{opacity:.3}.op4{opacity:.4}.op5{opacity:.5}.op6{opacity:.6}.op7{opacity:.7}.op8{opacity:.8}.op9{opacity:.9}.ls1-{letter-spacing:-1px}.ls2-{letter-spacing:-2px}.ls3-{letter-spacing:-3px}.ls1{letter-spacing:1px}.ls2{letter-spacing:2px}.ls3{letter-spacing:3px}.fz12{font-size:12px}.fz14{font-size:14px}.fz15{font-size:15px}.fz16{font-size:16px}.fz17{font-size:17px}.fz18{font-size:18px}.fz20{font-size:20px}.fz22{font-size:22px}.fz24{font-size:24px}.fz30{font-size:30px}.mt5{margin-top:5px}.mt10{margin-top:10px}.mt20{margin-top:20px}.mt30{margin-top:30px}.mb5{margin-bottom:5px}.mb10{margin-bottom:10px}.mr5{margin-right:5px}.c1{color:#111}.c2{color:#222}.c3{color:#333}.c4{color:#444}.c5{color:#555}.c6{color:#666}.c7{color:#777}.c8{color:#888}.c9{color:#999}.white{color:#fff}.black{color:#000}.c-b3{color:#b3b3b3}.c-red{color:#ff5040}.c-24{color:#242424}.c-green{color:#0c8}.tac{text-align:center}.tar{text-align:right}.tal{text-align:left}.taj{text-align:justify}.fl{float:left}.fr{float:right}.pt0{padding-top:0}.pt10{padding-top:10px}.p20{padding:20px}.pt20{padding-top:20px}.pt40{padding-top:40px}.pb20{padding-bottom:20px}.pb40{padding-bottom:40px}.vam{vertical-align:middle}.vat{vertical-align:top}.vab{vertical-align:bottom}.n{font-weight:400;font-style:normal}.b{font-weight:700}.f100{font-weight:100}.i{font-style:italic}.ovh{overflow:hidden}.ovs{overflow:scroll}.ff{font-family:PingFang-SC-Medium}.fs{font-style:normal}.fcolor{color:#ff5b05}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.clear{zoom:1}.clear:after{content:"";display:block;clear:both}.line1{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.line2{-webkit-line-clamp:2}.line2,.line3{display:-webkit-box;overflow:hidden}.line3{-webkit-line-clamp:3}.cup{cursor:pointer}.mauto{margin:0 auto}.bg-white{background:#fff}.bg-black{background:#000}.btn:active,btn.active{background-image:none;outline:0;box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn{display:inline-block;padding:6px 12px;cursor:pointer;border:1px solid transparent;border-radius:4px}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:active:hover{color:#333;background-color:#d4d4d4;border-color:#8c8c8c}.btn-default:hover{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-primary{color:#fff;background-color:#3190e8;border-color:#338de0}.btn-primary:hover{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary:active:hover{color:#fff;background-color:#204d74;border-color:#122b40}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:active:hover{color:#fff;background-color:#378037;border-color:#8c8c8c}.btn-success:hover{color:#fff;background-color:#449d44;border-color:#adadad}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:active:hover{color:#fff;background-color:#ac2925;border-color:#761c19}.btn-danger:hover{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-block{width:100%;display:block}.box-c{padding-left:15px;padding-right:15px}.yui-cells{background-color:#fff;line-height:1.41176471;font-size:16px;overflow:hidden;position:relative}.yui-cell{padding:15px;position:relative;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.yui-cell__bd{-webkit-flex:1;-ms-flex:1;flex:1}.yui-cell_access .yui-cell__ft{padding-right:16px;position:relative}.yui-cell__ft{text-align:right;color:rgba(0,0,0,.5)}.train-warp .am-list-item .am-list-line .am-list-extra:after,.yui-cell_access .yui-cell__ft:after{content:" ";display:inline-block;height:6px;width:6px;border-color:#242424;border-style:solid;border-width:2px 2px 0 0;-webkit-transform:matrix(.71,.71,-.71,.71,0,0);-ms-transform:matrix(.71,.71,-.71,.71,0,0);transform:matrix(.71,.71,-.71,.71,0,0);position:absolute;top:50%;margin-top:-5px;right:0}.yui-cell:after{content:" ";position:absolute;bottom:0;height:1px;border-top:1px solid #e0e0e0;color:#e0e0e0;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5);left:15px;right:15px;z-index:2}.yui-cell:first-child:before{display:none}.yui-textarea{border:1px solid #e0e0e0;display:block;resize:none;width:100%;color:inherit;font-size:1em;line-height:inherit;outline:0;padding:10px;border-radius:4px}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#242424;color:#b3b3b3}input::-moz-placeholder,textarea::-moz-placeholder{color:#242424;color:#b3b3b3}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#242424;color:#b3b3b3}input::placeholder,textarea::placeholder{color:#242424;color:#b3b3b3}.bg-yellow{background:#fff5dd}.orange{color:#ff8f00}.blue{color:#1da1f2}.y-dialog-wrap{position:fixed;top:0;bottom:0;left:0;right:0;z-index:1001}.y-dialog-wrap .y-dialog{position:absolute;padding-top:50px;padding-bottom:30px;z-index:1002;left:50%;top:50%;width:80%;-ms-transform:translate(-50%,-60%);transform:translate(-50%,-60%);-webkit-transform:translate(-50%,-60%);background-color:#fff;border-radius:8px;font-size:14px;box-shadow:0 2px 12px 0 rgba(0,0,0,.1)}.y-dialog-wrap .y-dialog .y-dialog-header{position:absolute;top:0;left:0;right:0;height:50px;line-height:50px;text-align:center}.y-dialog-wrap .y-dialog .y-dialog-header h2{font-size:16px}.y-dialog-wrap .y-dialog .y-dialog-content{overflow:auto;-webkit-overflow-scrolling:touch;height:100%;width:100%}.y-dialog-wrap .y-dialog .y-dialog-btn{width:100%;padding-top:30px}.y-dialog-wrap .y-dialog .y-dialog-btn .am-button{width:100%;border-radius:25px}.y-dialog-wrap .y-dialog .y-dialog-close{position:absolute;bottom:-50px;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.y-dialog-wrap.hide{display:none}.y-modal{position:fixed;left:0;top:0;width:100%;height:100%;opacity:.5;background:#000}[class*=" y-icon"],[class^=y-icon]{display:inline-block;vertical-align:middle;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;background-size:contain;background-position:0 0;background-repeat:no-repeat}.y-icon-close-border{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAC3UExURUdwTP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3XVmpgAAAA8dFJOUwCA/aulA4NX/A9DI5zr52ExDMQByB5x5kU76Y7YYiYCuHM61SDcNvnsEwYz38uNNbJTfhXv0n9chAixXV7MnDwAAAH6SURBVFjDrVfZloIwDA1aEAR3VFTEfQEBBXfl/79rRmeckQIVjHnQc5reS9uktwlAgm09nzj2crFY2g7xvS1kspW7321O1/nUtCxzOr+eNru9u0qLro0ms8OaDw/y68NsMqqlgEtciYzjXWNS4qRX+EpZkZO9slKuMOHNulplf6Cq1pvJ3k671Xi1xEar3Uny9btamkPWuv3Y8UFPN9KFydB7gxj8ZSilDbQ0vEQZekM+faLxw15k/7qUJVUlnTqHTtfIluxGNxSLZluDjKa1n/Oh3oLM1qo/5a/ayE7QUP+yWipX4Q2rlh/nzinwlinc7/0vye8RyKUffRgRynEW8sXo9GJeOFNDZHT/m9D6IQSBWKDxBTEIBFphJnf9m9Fz80GU4YYP8vTM2U0n3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R2i8x2h8h+l8h2h8h2h8h2h8h2i8x6h9H///x6i8x6h8h6i8x6l9R2h8h2m9R2h8iSq8h6i8h2h8h+h8yKq/ySj/x6i8x+q9B6j8h+h8h2j9R+n9x2h8h+j9R2i8x6h8iqq/x2h8n/BfGcAAAChdFJOUwD8+yn+CAP99/ouYQs14hLcVgmywwEiWcTyd3Q2EBnZnTHjBXgTzlG9whYsFLzMI3vl7qqO3eEe6bT5xzzVOgp+oOfvSMjmfHElV4R2sDdf1u1DhVWRb0yCuZReBMtASloRDC9L1E1Fi4gq859QpIebytsXJ6L0Y/FrG5CzyR0cmvgo4PCjwF0CW32XM9oaphVm9XMPDmwYZFJOIJM4rakGRIYsLAAAAcxJREFUKM+NUudfE0EUvCSX3B0hDVIIHQwIkQSS0MFGU8FGE3uhFwsoxQ6IVAWlCHaY/5TN7jUwH3wf5s282X27b3/Lcbo4qPKaucTxzbdfzQOI1nwP/mOmBD4Sq7ayQiRpfvjRUddmB5Z2f3kI3bOmCoj26N2HIu7d12TfLQiXNfmEx+27R7qlC7io8KQxBCjpfZDxbMZEaStvaGKupxCPKRmqJNeCkJscFxfQQDO3igU6bKYgldkmfc8xRctpOEfzOpZpLoQrnl5Pg/Y/A//Z+MmIrMRlEBXssCJY5e0nCa7hE1VXc3KZHcIdmjNwnmAqXaTFKaPkZQPhNMEwPutdUz5uMpaFRoIRbOjczHZ0KlwEmciJUs295DdeU7jFYLBwnBv1mn0F6SrPRgvBL9hUKxbJmKyKDjQTtKJGrRRcd2udutFG8KsgFiT6PSfssHF08HK1udWl2q8w4KHvINR+kEs3gC6ZllRjkLE55GQx1i+Io3LrYhQp3zCMYgej3hKWzTHYXyjHzObDmaS/VtUEXuZpMvsdDOPvFeUYEeE06Zeb30jg68pc9X9+bIeM4J86jo1ZurgFOaS3eQneIeVnecxd9/e3b4f77zgEOB9reHbPb50AAAAASUVORK5CYII=);width:15px;height:15px}.am-toast-notice-content .am-toast-text{min-width:100px}.am-modal{margin-bottom:60px}.am-image-picker-list{padding:9px 0}.button-primary{background:#1da1f2;border-radius:20px;color:#fff;padding:10px 20px}.am-button{height:45px;line-height:45px}.am-button[disabled]{background-color:#ddd}.am-button[disabled]:before{border:1px solid #ddd!important}.am-list-item .am-list-line .am-list-extra,.deposit-user .my-list .am-list-item .am-list-line .am-list-content{padding:0 20px}.am-modal-footer .am-modal-button-group-h .am-modal-button{color:#1da1f2}.navBarWrap .am-navbar{background:#494751}html:not([data-scale]) .am-list-body:after,html:not([data-scale]) .am-list-body:before{width:0}.am-list-item .am-list-line .am-list-content{font-size:16px}.am-list-item .am-list-line .am-list-extra{color:#b3b3b3;font-size:14px}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:2dppx){html:not([data-scale]) .am-list-body div:not(:last-child) .am-list-line:after{right:15px;width:inherit}}.photo-wrap{position:relative}.photo-wrap .pswp-thumbnails{position:absolute;z-index:-1;top:0;width:100%;padding:9px 8px 0;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.photo-wrap .pswp-thumbnails .pswp-thumbnail{-webkit-flex:1;-ms-flex:1;flex:1;height:78px;overflow:hidden;margin-right:5px;opacity:0}.pswp__top-bar .pswp__button:not(:first-of-type){display:none}.bottom-operate{position:fixed;bottom:0;left:0;right:0;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center;padding:10px 15px;background-color:#fff;box-shadow:0 -2px 4px 0 rgba(0,0,0,.04)}.bottom-operate .am-button{width:100%;border-radius:30px}.train-warp{padding-bottom:64px}.train-warp .train-list{height:100%;background-color:#f0f0f0;overflow:hidden}.train-warp .train-list .train-item{background-color:#fff;margin-bottom:14px;position:relative}.train-warp .train-list .train-item .y-icon-collate{position:absolute;right:16px;top:0}.train-warp .train-list .train-item .item-head{color:#999;padding-top:10px;padding-bottom:10px}.train-warp .train-list .train-item .item-body{background-color:#f9f9f9;padding-top:15px;padding-bottom:15px}.train-warp .train-list .train-item .item-body .train-head{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;width:70px;height:70px;overflow:hidden;background-position:50%;background-repeat:no-repeat;background-size:contain;border:1px solid #e0e0e0;margin-right:10px}.train-warp .train-list .train-item .item-body .body-con{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;text-align:left;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.train-warp .train-list .train-item .item-operate{padding-top:8px;padding-bottom:8px;text-align:right}.train-warp .train-list .train-item .item-operate .o-btn{display:inline-block;padding:5px 22px;font-size:13px;border:1px solid #999;margin-left:10px;border-radius:20px}.train-warp .train-list .train-item .item-operate .o-btn.disabled{color:#bfbfbf;border:1px solid #bfbfbf}.train-warp .add-train{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-120%);-ms-transform:translate(-50%,-120%);transform:translate(-50%,-120%);width:205px;height:55px;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border-radius:30px;color:#fff;background-color:#1da1f2;font-size:17px}.train-warp .add-train .y-icon-add{width:17px;height:17px;margin-right:8px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiBAMAAADIaRbxAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAPUExURUdwTP///////////////xPgMRoAAAAEdFJOUwDmiAYExX3+AAAAQklEQVQoz2NggAAjQWUGVKDi4oQmIuLiiCbi4uIylEWMRFyQgaMy0NOowIlBBE3EEYsIpi5Mk4dHiOFMCZipBZGiAI8nLn1hShW3AAAAAElFTkSuQmCC)}.nav-bar{position:relative;height:42px;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;position:fixed;top:0;z-index:10;width:100%;background:#fff}.nav-bar .item-bar{-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;font-size:13px;color:#666;height:42px;line-height:42px;text-align:center}.nav-bar .item-bar:after{position:absolute;content:" ";bottom:0;left:0;right:0;border-bottom:1px solid #f0f0f0;-webkit-transform:translateY(.5);-ms-transform:translateY(.5);transform:translateY(.5)}.nav-bar .item-bar span{position:relative;display:inline-block;height:100%}.nav-bar .item-bar.active{color:#242424;font-size:15px;font-weight:700}.nav-bar .item-bar.active span:after{content:" ";position:absolute;bottom:1px;left:0;width:100%;height:4px;background:#1da1f2;border-top-left-radius:3px;border-top-right-radius:3px}.job-list-wrap{padding-top:42px}.swiper-box{height:100%}.swiper-box .swiper-item{height:100%;display:none}.swiper-box .swiper-item.active{display:block}.am-list-body .am-list-item .am-list-line{padding-top:10px;padding-bottom:10px}.am-list-body .am-list-item .am-list-line .am-list-extra:after{right:15px}.am-list-content{font-weight:700;font-size:16px}.tip-right{position:absolute;color:#1da1f2;right:0;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%)}.dialog-intro{padding-left:30px;padding-right:30px;background-size:contain;background-repeat:no-repeat;background-image:url(//img/safe-bg@2x.639ee009.png)}.dialog-intro .title{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAwCAMAAAAICtykAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURUdwTCQkJCgoKCYmJiUlJSYmJiUlJSQkJCQkJDMzMyUlJSQkJCQkJCQkJCQkJCYmJiUlJSoqKiQkJCQkJCUlJSQkJCUlJSQkJCQkJCQkJP///yQkJCQkJCoqKioqKikpKSQkJCQkJCQkJCQkJCQkJCQkJC4uLigoKCQkJDg4OC4uLiUlJS4uLiQkJCUlJVVVVSUlJSQkJDMzMyQkJD8/PycnJykpKSQkJCQkJCQkJCQkJCQkJH9/fyUlJSUlJSQkJCQkJCQkJCYmJiUlJSQkJCUlJScnJyQkJCQkJCQkJCUlJSQkJDU1NSQkJCUlJS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L+pE9CbutX9S7TbRvjPIiRYwtMjb1hpvth9/UZU9BZtpRDfBxriHRnoZzTVDxbtRVHUaEENB/ehQoC/AkJACABCQAgAQkAIAEJACPBrHnMpf8Vd8IxiAAAAAElFTkSuQmCC) 0 0 no-repeat;background-size:contain;width:200px;height:24px;margin-bottom:16px}
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="dns-prefetch" href="http://192.168.48.140">
<link rel="dns-prefetch" href="http://192.168.48.140:8080">
<title>Document</title>
<link href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.min.css" rel="stylesheet">
<link href="vendors~app.b1ea6b3e.css" rel="stylesheet">
<link href="app.5d542828.css" rel="stylesheet">
<link as="script" href="app.195e856e.js" rel="preload">
<link as="style" href="app.5d542828.css" rel="preload">
<link as="script" href="runtime~app.558836ef.js" rel="preload">
<link as="script" href="runtime~vendor.2d1aae0e.js" rel="preload">
<link as="script" href="vendor.291365be.js" rel="preload">
<link as="script" href="vendors~app.8ec15845.js" rel="preload">
<link as="style" href="vendors~app.b1ea6b3e.css" rel="preload">
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="runtime~app.558836ef.js"></script>
<script type="text/javascript" src="vendors~app.8ec15845.js"></script>
<script type="text/javascript" src="app.195e856e.js"></script>
<script type="text/javascript" src="runtime~vendor.2d1aae0e.js"></script>
<script type="text/javascript" src="vendor.291365be.js"></script>
</body>
<script>
window.onload = function () {
var n = document.createElement("style"), e = document.documentElement.clientWidth / 16; n.innerHTML = "html{font-size:" + e + "px !important}", document.body.appendChild(n)
}</script>
</html>
\ No newline at end of file
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="keywords" content="健康,健康心理测试,健康在线心理测试,健康免费心理测试,健康心理测试题,健康心理测试小游戏,健康心理测试工具"/><meta name="description" content="壹点灵心理测试频道为您提供专业,贴心的免费健康心理测试题库,和免费的健康心理测试小游戏,动动手指,立刻免费在线健康心理测试。"/><title>壹点零</title><link href="/vendors~app.b1ea6b3e.css" rel="stylesheet"><link href="/app.fcd5fb51.css" rel="stylesheet"><link as="script" href="/app.6daef0c5.js" rel="preload"><link as="style" href="/app.fcd5fb51.css" rel="preload"><link as="script" href="/runtime~app.2fa568f7.js" rel="preload"><link as="script" href="/runtime~vendor.ddec352d.js" rel="preload"><link as="script" href="/vendor.291365be.js" rel="preload"><link as="style" href="/vendors~app.b1ea6b3e.css" rel="preload"><link as="script" href="/vendors~app.fc3abd48.js" rel="preload"></head><body><div id="root"></div><script type="text/javascript" src="/runtime~app.2fa568f7.js"></script><script type="text/javascript" src="/vendors~app.fc3abd48.js"></script><script type="text/javascript" src="/app.6daef0c5.js"></script><script type="text/javascript" src="/runtime~vendor.ddec352d.js"></script><script type="text/javascript" src="/vendor.291365be.js"></script></body><script>window.onload=function(){var n=document.createElement("style"),e=document.documentElement.clientWidth/16;n.innerHTML="html{font-size:"+e+"px !important}",document.body.appendChild(n)}</script></html>
\ No newline at end of file
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "639ee00928fb124d43dbf26af523c48f",
"url": "/img/safe-bg@2x.639ee009.png"
},
{
"revision": "fe67cdda333caf2e3f9c",
"url": "app.195e856e.js"
},
{
"revision": "fe67cdda333caf2e3f9c",
"url": "app.5d542828.css"
},
{
"revision": "05704ad89623388e73f1f162b113dd39",
"url": "index.html"
},
{
"revision": "879a59d63331da3bcc85",
"url": "runtime~app.558836ef.js"
},
{
"revision": "f6b7f0f43ede93c7111d",
"url": "runtime~vendor.2d1aae0e.js"
},
{
"revision": "88a08b4e5eb5bfeac176",
"url": "vendor.291365be.js"
},
{
"revision": "5e26fc6e254e4e8624ad",
"url": "vendors~app.8ec15845.js"
},
{
"revision": "5e26fc6e254e4e8624ad",
"url": "vendors~app.b1ea6b3e.css"
}
]);
\ No newline at end of file
!function(e){function r(r){for(var n,f,i=r[0],l=r[1],a=r[2],c=0,s=[];c<i.length;c++)f=i[c],o[f]&&s.push(o[f][0]),o[f]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="";var i=window.webpackJsonp=window.webpackJsonp||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=l;t()}([]);
\ No newline at end of file
!function(e){function r(r){for(var n,f,i=r[0],l=r[1],a=r[2],c=0,s=[];c<i.length;c++)f=i[c],o[f]&&s.push(o[f][0]),o[f]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var i=window.webpackJsonp=window.webpackJsonp||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=l;t()}([]);
\ No newline at end of file
!function(e){function r(r){for(var n,f,i=r[0],l=r[1],a=r[2],c=0,s=[];c<i.length;c++)f=i[c],o[f]&&s.push(o[f][0]),o[f]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={2:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="";var i=window.webpackJsonp=window.webpackJsonp||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=l;t()}([]);
\ No newline at end of file
!function(e){function r(r){for(var n,f,i=r[0],l=r[1],a=r[2],c=0,s=[];c<i.length;c++)f=i[c],o[f]&&s.push(o[f][0]),o[f]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={2:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var i=window.webpackJsonp=window.webpackJsonp||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var a=0;a<i.length;a++)r(i[a]);var p=l;t()}([]);
\ No newline at end of file
/**
* Welcome to your Workbox-powered service worker!
*
* You'll need to register this file in your web app and you should
* disable HTTP caching for this file too.
* See https://goo.gl/nhQhGp
*
* The rest of the code is auto-generated. Please don't update this file
* directly; instead, make changes to your Workbox build configuration
* and re-run your build process.
* See https://goo.gl/2aRDsh
*/
importScripts("workbox-v4.3.1/workbox-sw.js");
workbox.setConfig({modulePathPrefix: "workbox-v4.3.1"});
importScripts(
"precache-manifest.f5c34b60f6b4002369ca8380e66bdfff.js"
);
workbox.core.skipWaiting();
workbox.core.clientsClaim();
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
This source diff could not be displayed because it is too large. You can view the blob instead.
this.workbox = this.workbox || {};
this.workbox.backgroundSync = (function (exports, WorkboxError_mjs, logger_mjs, assert_mjs, getFriendlyURL_mjs, DBWrapper_mjs) {
'use strict';
try {
self['workbox:background-sync:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const DB_VERSION = 3;
const DB_NAME = 'workbox-background-sync';
const OBJECT_STORE_NAME = 'requests';
const INDEXED_PROP = 'queueName';
/**
* A class to manage storing requests from a Queue in IndexedbDB,
* indexed by their queue name for easier access.
*
* @private
*/
class QueueStore {
/**
* Associates this instance with a Queue instance, so entries added can be
* identified by their queue name.
*
* @param {string} queueName
* @private
*/
constructor(queueName) {
this._queueName = queueName;
this._db = new DBWrapper_mjs.DBWrapper(DB_NAME, DB_VERSION, {
onupgradeneeded: this._upgradeDb
});
}
/**
* Append an entry last in the queue.
*
* @param {Object} entry
* @param {Object} entry.requestData
* @param {number} [entry.timestamp]
* @param {Object} [entry.metadata]
* @private
*/
async pushEntry(entry) {
{
assert_mjs.assert.isType(entry, 'object', {
moduleName: 'workbox-background-sync',
className: 'QueueStore',
funcName: 'pushEntry',
paramName: 'entry'
});
assert_mjs.assert.isType(entry.requestData, 'object', {
moduleName: 'workbox-background-sync',
className: 'QueueStore',
funcName: 'pushEntry',
paramName: 'entry.requestData'
});
} // Don't specify an ID since one is automatically generated.
delete entry.id;
entry.queueName = this._queueName;
await this._db.add(OBJECT_STORE_NAME, entry);
}
/**
* Preppend an entry first in the queue.
*
* @param {Object} entry
* @param {Object} entry.requestData
* @param {number} [entry.timestamp]
* @param {Object} [entry.metadata]
* @private
*/
async unshiftEntry(entry) {
{
assert_mjs.assert.isType(entry, 'object', {
moduleName: 'workbox-background-sync',
className: 'QueueStore',
funcName: 'unshiftEntry',
paramName: 'entry'
});
assert_mjs.assert.isType(entry.requestData, 'object', {
moduleName: 'workbox-background-sync',
className: 'QueueStore',
funcName: 'unshiftEntry',
paramName: 'entry.requestData'
});
}
const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {
count: 1
});
if (firstEntry) {
// Pick an ID one less than the lowest ID in the object store.
entry.id = firstEntry.id - 1;
} else {
// Otherwise let the auto-incrementor assign the ID.
delete entry.id;
}
entry.queueName = this._queueName;
await this._db.add(OBJECT_STORE_NAME, entry);
}
/**
* Removes and returns the last entry in the queue matching the `queueName`.
*
* @return {Promise<Object>}
* @private
*/
async popEntry() {
return this._removeEntry({
direction: 'prev'
});
}
/**
* Removes and returns the first entry in the queue matching the `queueName`.
*
* @return {Promise<Object>}
* @private
*/
async shiftEntry() {
return this._removeEntry({
direction: 'next'
});
}
/**
* Returns all entries in the store matching the `queueName`.
*
* @param {Object} options See workbox.backgroundSync.Queue~getAll}
* @return {Promise<Array<Object>>}
* @private
*/
async getAll() {
return await this._db.getAllMatching(OBJECT_STORE_NAME, {
index: INDEXED_PROP,
query: IDBKeyRange.only(this._queueName)
});
}
/**
* Deletes the entry for the given ID.
*
* WARNING: this method does not ensure the deleted enry belongs to this
* queue (i.e. matches the `queueName`). But this limitation is acceptable
* as this class is not publicly exposed. An additional check would make
* this method slower than it needs to be.
*
* @private
* @param {number} id
*/
async deleteEntry(id) {
await this._db.delete(OBJECT_STORE_NAME, id);
}
/**
* Removes and returns the first or last entry in the queue (based on the
* `direction` argument) matching the `queueName`.
*
* @return {Promise<Object>}
* @private
*/
async _removeEntry({
direction
}) {
const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {
direction,
index: INDEXED_PROP,
query: IDBKeyRange.only(this._queueName),
count: 1
});
if (entry) {
await this.deleteEntry(entry.id);
return entry;
}
}
/**
* Upgrades the database given an `upgradeneeded` event.
*
* @param {Event} event
* @private
*/
_upgradeDb(event) {
const db = event.target.result;
if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {
if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {
db.deleteObjectStore(OBJECT_STORE_NAME);
}
}
const objStore = db.createObjectStore(OBJECT_STORE_NAME, {
autoIncrement: true,
keyPath: 'id'
});
objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {
unique: false
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive'];
/**
* A class to make it easier to serialize and de-serialize requests so they
* can be stored in IndexedDB.
*
* @private
*/
class StorableRequest {
/**
* Converts a Request object to a plain object that can be structured
* cloned or JSON-stringified.
*
* @param {Request} request
* @return {Promise<StorableRequest>}
*
* @private
*/
static async fromRequest(request) {
const requestData = {
url: request.url,
headers: {}
}; // Set the body if present.
if (request.method !== 'GET') {
// Use ArrayBuffer to support non-text request bodies.
// NOTE: we can't use Blobs becuse Safari doesn't support storing
// Blobs in IndexedDB in some cases:
// https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457
requestData.body = await request.clone().arrayBuffer();
} // Convert the headers from an iterable to an object.
for (const [key, value] of request.headers.entries()) {
requestData.headers[key] = value;
} // Add all other serializable request properties
for (const prop of serializableProperties) {
if (request[prop] !== undefined) {
requestData[prop] = request[prop];
}
}
return new StorableRequest(requestData);
}
/**
* Accepts an object of request data that can be used to construct a
* `Request` but can also be stored in IndexedDB.
*
* @param {Object} requestData An object of request data that includes the
* `url` plus any relevant properties of
* [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.
* @private
*/
constructor(requestData) {
{
assert_mjs.assert.isType(requestData, 'object', {
moduleName: 'workbox-background-sync',
className: 'StorableRequest',
funcName: 'constructor',
paramName: 'requestData'
});
assert_mjs.assert.isType(requestData.url, 'string', {
moduleName: 'workbox-background-sync',
className: 'StorableRequest',
funcName: 'constructor',
paramName: 'requestData.url'
});
} // If the request's mode is `navigate`, convert it to `same-origin` since
// navigation requests can't be constructed via script.
if (requestData.mode === 'navigate') {
requestData.mode = 'same-origin';
}
this._requestData = requestData;
}
/**
* Returns a deep clone of the instances `_requestData` object.
*
* @return {Object}
*
* @private
*/
toObject() {
const requestData = Object.assign({}, this._requestData);
requestData.headers = Object.assign({}, this._requestData.headers);
if (requestData.body) {
requestData.body = requestData.body.slice(0);
}
return requestData;
}
/**
* Converts this instance to a Request.
*
* @return {Request}
*
* @private
*/
toRequest() {
return new Request(this._requestData.url, this._requestData);
}
/**
* Creates and returns a deep clone of the instance.
*
* @return {StorableRequest}
*
* @private
*/
clone() {
return new StorableRequest(this.toObject());
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const TAG_PREFIX = 'workbox-background-sync';
const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes
const queueNames = new Set();
/**
* A class to manage storing failed requests in IndexedDB and retrying them
* later. All parts of the storing and replaying process are observable via
* callbacks.
*
* @memberof workbox.backgroundSync
*/
class Queue {
/**
* Creates an instance of Queue with the given options
*
* @param {string} name The unique name for this queue. This name must be
* unique as it's used to register sync events and store requests
* in IndexedDB specific to this instance. An error will be thrown if
* a duplicate name is detected.
* @param {Object} [options]
* @param {Function} [options.onSync] A function that gets invoked whenever
* the 'sync' event fires. The function is invoked with an object
* containing the `queue` property (referencing this instance), and you
* can use the callback to customize the replay behavior of the queue.
* When not set the `replayRequests()` method is called.
* Note: if the replay fails after a sync event, make sure you throw an
* error, so the browser knows to retry the sync event later.
* @param {number} [options.maxRetentionTime=7 days] The amount of time (in
* minutes) a request may be retried. After this amount of time has
* passed, the request will be deleted from the queue.
*/
constructor(name, {
onSync,
maxRetentionTime
} = {}) {
// Ensure the store name is not already being used
if (queueNames.has(name)) {
throw new WorkboxError_mjs.WorkboxError('duplicate-queue-name', {
name
});
} else {
queueNames.add(name);
}
this._name = name;
this._onSync = onSync || this.replayRequests;
this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;
this._queueStore = new QueueStore(this._name);
this._addSyncListener();
}
/**
* @return {string}
*/
get name() {
return this._name;
}
/**
* Stores the passed request in IndexedDB (with its timestamp and any
* metadata) at the end of the queue.
*
* @param {Object} entry
* @param {Request} entry.request The request to store in the queue.
* @param {Object} [entry.metadata] Any metadata you want associated with the
* stored request. When requests are replayed you'll have access to this
* metadata object in case you need to modify the request beforehand.
* @param {number} [entry.timestamp] The timestamp (Epoch time in
* milliseconds) when the request was first added to the queue. This is
* used along with `maxRetentionTime` to remove outdated requests. In
* general you don't need to set this value, as it's automatically set
* for you (defaulting to `Date.now()`), but you can update it if you
* don't want particular requests to expire.
*/
async pushRequest(entry) {
{
assert_mjs.assert.isType(entry, 'object', {
moduleName: 'workbox-background-sync',
className: 'Queue',
funcName: 'pushRequest',
paramName: 'entry'
});
assert_mjs.assert.isInstance(entry.request, Request, {
moduleName: 'workbox-background-sync',
className: 'Queue',
funcName: 'pushRequest',
paramName: 'entry.request'
});
}
await this._addRequest(entry, 'push');
}
/**
* Stores the passed request in IndexedDB (with its timestamp and any
* metadata) at the beginning of the queue.
*
* @param {Object} entry
* @param {Request} entry.request The request to store in the queue.
* @param {Object} [entry.metadata] Any metadata you want associated with the
* stored request. When requests are replayed you'll have access to this
* metadata object in case you need to modify the request beforehand.
* @param {number} [entry.timestamp] The timestamp (Epoch time in
* milliseconds) when the request was first added to the queue. This is
* used along with `maxRetentionTime` to remove outdated requests. In
* general you don't need to set this value, as it's automatically set
* for you (defaulting to `Date.now()`), but you can update it if you
* don't want particular requests to expire.
*/
async unshiftRequest(entry) {
{
assert_mjs.assert.isType(entry, 'object', {
moduleName: 'workbox-background-sync',
className: 'Queue',
funcName: 'unshiftRequest',
paramName: 'entry'
});
assert_mjs.assert.isInstance(entry.request, Request, {
moduleName: 'workbox-background-sync',
className: 'Queue',
funcName: 'unshiftRequest',
paramName: 'entry.request'
});
}
await this._addRequest(entry, 'unshift');
}
/**
* Removes and returns the last request in the queue (along with its
* timestamp and any metadata). The returned object takes the form:
* `{request, timestamp, metadata}`.
*
* @return {Promise<Object>}
*/
async popRequest() {
return this._removeRequest('pop');
}
/**
* Removes and returns the first request in the queue (along with its
* timestamp and any metadata). The returned object takes the form:
* `{request, timestamp, metadata}`.
*
* @return {Promise<Object>}
*/
async shiftRequest() {
return this._removeRequest('shift');
}
/**
* Returns all the entries that have not expired (per `maxRetentionTime`).
* Any expired entries are removed from the queue.
*
* @return {Promise<Array<Object>>}
*/
async getAll() {
const allEntries = await this._queueStore.getAll();
const now = Date.now();
const unexpiredEntries = [];
for (const entry of allEntries) {
// Ignore requests older than maxRetentionTime. Call this function
// recursively until an unexpired request is found.
const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;
if (now - entry.timestamp > maxRetentionTimeInMs) {
await this._queueStore.deleteEntry(entry.id);
} else {
unexpiredEntries.push(convertEntry(entry));
}
}
return unexpiredEntries;
}
/**
* Adds the entry to the QueueStore and registers for a sync event.
*
* @param {Object} entry
* @param {Request} entry.request
* @param {Object} [entry.metadata]
* @param {number} [entry.timestamp=Date.now()]
* @param {string} operation ('push' or 'unshift')
* @private
*/
async _addRequest({
request,
metadata,
timestamp = Date.now()
}, operation) {
const storableRequest = await StorableRequest.fromRequest(request.clone());
const entry = {
requestData: storableRequest.toObject(),
timestamp
}; // Only include metadata if it's present.
if (metadata) {
entry.metadata = metadata;
}
await this._queueStore[`${operation}Entry`](entry);
{
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}' has ` + `been added to background sync queue '${this._name}'.`);
} // Don't register for a sync if we're in the middle of a sync. Instead,
// we wait until the sync is complete and call register if
// `this._requestsAddedDuringSync` is true.
if (this._syncInProgress) {
this._requestsAddedDuringSync = true;
} else {
await this.registerSync();
}
}
/**
* Removes and returns the first or last (depending on `operation`) entry
* from the QueueStore that's not older than the `maxRetentionTime`.
*
* @param {string} operation ('pop' or 'shift')
* @return {Object|undefined}
* @private
*/
async _removeRequest(operation) {
const now = Date.now();
const entry = await this._queueStore[`${operation}Entry`]();
if (entry) {
// Ignore requests older than maxRetentionTime. Call this function
// recursively until an unexpired request is found.
const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;
if (now - entry.timestamp > maxRetentionTimeInMs) {
return this._removeRequest(operation);
}
return convertEntry(entry);
}
}
/**
* Loops through each request in the queue and attempts to re-fetch it.
* If any request fails to re-fetch, it's put back in the same position in
* the queue (which registers a retry for the next sync event).
*/
async replayRequests() {
let entry;
while (entry = await this.shiftRequest()) {
try {
await fetch(entry.request.clone());
{
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(entry.request.url)}'` + `has been replayed in queue '${this._name}'`);
}
} catch (error) {
await this.unshiftRequest(entry);
{
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(entry.request.url)}'` + `failed to replay, putting it back in queue '${this._name}'`);
}
throw new WorkboxError_mjs.WorkboxError('queue-replay-failed', {
name: this._name
});
}
}
{
logger_mjs.logger.log(`All requests in queue '${this.name}' have successfully ` + `replayed; the queue is now empty!`);
}
}
/**
* Registers a sync event with a tag unique to this instance.
*/
async registerSync() {
if ('sync' in registration) {
try {
await registration.sync.register(`${TAG_PREFIX}:${this._name}`);
} catch (err) {
// This means the registration failed for some reason, possibly due to
// the user disabling it.
{
logger_mjs.logger.warn(`Unable to register sync event for '${this._name}'.`, err);
}
}
}
}
/**
* In sync-supporting browsers, this adds a listener for the sync event.
* In non-sync-supporting browsers, this will retry the queue on service
* worker startup.
*
* @private
*/
_addSyncListener() {
if ('sync' in registration) {
self.addEventListener('sync', event => {
if (event.tag === `${TAG_PREFIX}:${this._name}`) {
{
logger_mjs.logger.log(`Background sync for tag '${event.tag}'` + `has been received`);
}
const syncComplete = async () => {
this._syncInProgress = true;
let syncError;
try {
await this._onSync({
queue: this
});
} catch (error) {
syncError = error; // Rethrow the error. Note: the logic in the finally clause
// will run before this gets rethrown.
throw syncError;
} finally {
// New items may have been added to the queue during the sync,
// so we need to register for a new sync if that's happened...
// Unless there was an error during the sync, in which
// case the browser will automatically retry later, as long
// as `event.lastChance` is not true.
if (this._requestsAddedDuringSync && !(syncError && !event.lastChance)) {
await this.registerSync();
}
this._syncInProgress = false;
this._requestsAddedDuringSync = false;
}
};
event.waitUntil(syncComplete());
}
});
} else {
{
logger_mjs.logger.log(`Background sync replaying without background sync event`);
} // If the browser doesn't support background sync, retry
// every time the service worker starts up as a fallback.
this._onSync({
queue: this
});
}
}
/**
* Returns the set of queue names. This is primarily used to reset the list
* of queue names in tests.
*
* @return {Set}
*
* @private
*/
static get _queueNames() {
return queueNames;
}
}
/**
* Converts a QueueStore entry into the format exposed by Queue. This entails
* converting the request data into a real request and omitting the `id` and
* `queueName` properties.
*
* @param {Object} queueStoreEntry
* @return {Object}
* @private
*/
const convertEntry = queueStoreEntry => {
const queueEntry = {
request: new StorableRequest(queueStoreEntry.requestData).toRequest(),
timestamp: queueStoreEntry.timestamp
};
if (queueStoreEntry.metadata) {
queueEntry.metadata = queueStoreEntry.metadata;
}
return queueEntry;
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A class implementing the `fetchDidFail` lifecycle callback. This makes it
* easier to add failed requests to a background sync Queue.
*
* @memberof workbox.backgroundSync
*/
class Plugin {
/**
* @param {...*} queueArgs Args to forward to the composed Queue instance.
* See the [Queue]{@link workbox.backgroundSync.Queue} documentation for
* parameter details.
*/
constructor(...queueArgs) {
this._queue = new Queue(...queueArgs);
this.fetchDidFail = this.fetchDidFail.bind(this);
}
/**
* @param {Object} options
* @param {Request} options.request
* @private
*/
async fetchDidFail({
request
}) {
await this._queue.pushRequest({
request
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.Queue = Queue;
exports.Plugin = Plugin;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-background-sync.dev.js.map
{"version":3,"file":"workbox-background-sync.dev.js","sources":["../_version.mjs","../lib/QueueStore.mjs","../lib/StorableRequest.mjs","../Queue.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:background-sync:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport '../_version.mjs';\n\n\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n } else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({direction: 'prev'});\n }\n\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({direction: 'next'});\n }\n\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({direction}) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {unique: false});\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n\n\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n\n return new StorableRequest(requestData);\n }\n\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n\n this._requestData = requestData;\n }\n\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n\n return requestData;\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\n\nexport {StorableRequest};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {QueueStore} from './lib/QueueStore.mjs';\nimport {StorableRequest} from './lib/StorableRequest.mjs';\nimport './_version.mjs';\n\n\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\nconst queueNames = new Set();\n\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {onSync, maxRetentionTime} = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', {name});\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'push');\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'unshift');\n }\n\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n } else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n\n return unexpiredEntries;\n }\n\n\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest(\n {request, metadata, timestamp = Date.now()}, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n\n await this._queueStore[`${operation}Entry`](entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n } else {\n await this.registerSync();\n }\n }\n\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n\n return convertEntry(entry);\n }\n }\n\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n } catch (error) {\n await this.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', {name: this._name});\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in registration) {\n try {\n await registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n\n const syncComplete = async () => {\n this._syncInProgress = true;\n\n let syncError;\n try {\n await this._onSync({queue: this});\n } catch (error) {\n syncError = error;\n\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n } finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({queue: this});\n }\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n\n\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\n\nexport {Queue};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Queue} from './Queue.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n async fetchDidFail({request}) {\n await this._queue.pushRequest({request});\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Queue} from './Queue.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.backgroundSync\n */\n\nexport {\n Queue,\n Plugin,\n};\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","_upgradeDb","pushEntry","entry","assert","isType","moduleName","className","funcName","paramName","requestData","id","add","unshiftEntry","firstEntry","getAllMatching","count","popEntry","_removeEntry","direction","shiftEntry","getAll","index","query","IDBKeyRange","only","deleteEntry","delete","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","objStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","fromRequest","request","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","pushRequest","isInstance","_addRequest","unshiftRequest","popRequest","_removeRequest","shiftRequest","allEntries","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","storableRequest","logger","log","getFriendlyURL","_syncInProgress","_requestsAddedDuringSync","registerSync","fetch","error","registration","sync","register","err","warn","addEventListener","tag","syncComplete","syncError","queue","lastChance","waitUntil","_queueNames","queueStoreEntry","queueEntry","Plugin","queueArgs","_queue","fetchDidFail","bind"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,+BAAD,CAAJ,IAAuCC,CAAC,EAAxC;EAA2C,CAA/C,CAA+C,OAAMC,CAAN,EAAQ;;ECAvD;;;;;;;AAQA,EAKA,MAAMC,UAAU,GAAG,CAAnB;EACA,MAAMC,OAAO,GAAG,yBAAhB;EACA,MAAMC,iBAAiB,GAAG,UAA1B;EACA,MAAMC,YAAY,GAAG,WAArB;EAEA;;;;;;;AAMA,EAAO,MAAMC,UAAN,CAAi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CD;EAqCD,KAtCD,MAsCO;EACL,MAA2C;EACzCf,QAAAA,iBAAM,CAACC,GAAP,CAAY,yDAAZ;EACD,OAHI;EAKL;;;EACA,WAAKxB,OAAL,CAAa;EAACwC,QAAAA,KAAK,EAAE;EAAR,OAAb;EACD;EACF;EAED;;;;;;;;;;EAQA,aAAWG,WAAX,GAAyB;EACvB,WAAOpD,UAAP;EACD;;EApVS;EAwVZ;;;;;;;;;;;EASA,MAAM4B,YAAY,GAAIyB,eAAD,IAAqB;EACxC,QAAMC,UAAU,GAAG;EACjB5E,IAAAA,OAAO,EAAE,IAAIF,eAAJ,CAAoB6E,eAAe,CAAC9G,WAApC,EAAiDqD,SAAjD,EADQ;EAEjB8B,IAAAA,SAAS,EAAE2B,eAAe,CAAC3B;EAFV,GAAnB;;EAIA,MAAI2B,eAAe,CAACxB,QAApB,EAA8B;EAC5ByB,IAAAA,UAAU,CAACzB,QAAX,GAAsBwB,eAAe,CAACxB,QAAtC;EACD;;EACD,SAAOyB,UAAP;EACD,CATD;;EC9XA;;;;;;;AAQA,EAGA;;;;;;;EAMA,MAAMC,MAAN,CAAa;EACX;;;;;EAKA/H,EAAAA,WAAW,CAAC,GAAGgI,SAAJ,EAAe;EACxB,SAAKC,MAAL,GAAc,IAAIvD,KAAJ,CAAU,GAAGsD,SAAb,CAAd;EACA,SAAKE,YAAL,GAAoB,KAAKA,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAApB;EACD;EAED;;;;;;;EAKA,QAAMD,YAAN,CAAmB;EAAChF,IAAAA;EAAD,GAAnB,EAA8B;EAC5B,UAAM,KAAK+E,MAAL,CAAY3C,WAAZ,CAAwB;EAACpC,MAAAA;EAAD,KAAxB,CAAN;EACD;;EAlBU;;ECjBb;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s){"use strict";try{self["workbox:background-sync:4.3.1"]&&_()}catch(t){}const i=3,n="workbox-background-sync",a="requests",r="queueName";class c{constructor(t){this.t=t,this.s=new s.DBWrapper(n,i,{onupgradeneeded:this.i})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.s.add(a,t)}async unshiftEntry(t){const[e]=await this.s.getAllMatching(a,{count:1});e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.s.add(a,t)}async popEntry(){return this.h({direction:"prev"})}async shiftEntry(){return this.h({direction:"next"})}async getAll(){return await this.s.getAllMatching(a,{index:r,query:IDBKeyRange.only(this.t)})}async deleteEntry(t){await this.s.delete(a,t)}async h({direction:t}){const[e]=await this.s.getAllMatching(a,{direction:t,index:r,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.deleteEntry(e.id),e}i(t){const e=t.target.result;t.oldVersion>0&&t.oldVersion<i&&e.objectStoreNames.contains(a)&&e.deleteObjectStore(a),e.createObjectStore(a,{autoIncrement:!0,keyPath:"id"}).createIndex(r,r,{unique:!1})}}const h=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class o{static async fromRequest(t){const e={url:t.url,headers:{}};"GET"!==t.method&&(e.body=await t.clone().arrayBuffer());for(const[s,i]of t.headers.entries())e.headers[s]=i;for(const s of h)void 0!==t[s]&&(e[s]=t[s]);return new o(e)}constructor(t){"navigate"===t.mode&&(t.mode="same-origin"),this.o=t}toObject(){const t=Object.assign({},this.o);return t.headers=Object.assign({},this.o.headers),t.body&&(t.body=t.body.slice(0)),t}toRequest(){return new Request(this.o.url,this.o)}clone(){return new o(this.toObject())}}const u="workbox-background-sync",y=10080,w=new Set;class d{constructor(t,{onSync:s,maxRetentionTime:i}={}){if(w.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});w.add(t),this.u=t,this.l=s||this.replayRequests,this.q=i||y,this.m=new c(this.u),this.p()}get name(){return this.u}async pushRequest(t){await this.g(t,"push")}async unshiftRequest(t){await this.g(t,"unshift")}async popRequest(){return this.R("pop")}async shiftRequest(){return this.R("shift")}async getAll(){const t=await this.m.getAll(),e=Date.now(),s=[];for(const i of t){const t=60*this.q*1e3;e-i.timestamp>t?await this.m.deleteEntry(i.id):s.push(f(i))}return s}async g({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await o.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.m[`${i}Entry`](n),this.k?this.D=!0:await this.registerSync()}async R(t){const e=Date.now(),s=await this.m[`${t}Entry`]();if(s){const i=60*this.q*1e3;return e-s.timestamp>i?this.R(t):f(s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request.clone())}catch(s){throw await this.unshiftRequest(t),new e.WorkboxError("queue-replay-failed",{name:this.u})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${u}:${this.u}`)}catch(t){}}p(){"sync"in registration?self.addEventListener("sync",t=>{if(t.tag===`${u}:${this.u}`){const e=async()=>{let e;this.k=!0;try{await this.l({queue:this})}catch(t){throw e=t}finally{!this.D||e&&!t.lastChance||await this.registerSync(),this.k=!1,this.D=!1}};t.waitUntil(e())}}):this.l({queue:this})}static get _(){return w}}const f=t=>{const e={request:new o(t.requestData).toRequest(),timestamp:t.timestamp};return t.metadata&&(e.metadata=t.metadata),e};return t.Queue=d,t.Plugin=class{constructor(...t){this.v=new d(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.v.pushRequest({request:t})}},t}({},workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-background-sync.prod.js.map
{"version":3,"file":"workbox-background-sync.prod.js","sources":["../_version.mjs","../lib/QueueStore.mjs","../lib/StorableRequest.mjs","../Queue.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:background-sync:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport '../_version.mjs';\n\n\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n } else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({direction: 'prev'});\n }\n\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({direction: 'next'});\n }\n\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({direction}) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {unique: false});\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n\n\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n\n return new StorableRequest(requestData);\n }\n\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n\n this._requestData = requestData;\n }\n\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n\n return requestData;\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\n\nexport {StorableRequest};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {QueueStore} from './lib/QueueStore.mjs';\nimport {StorableRequest} from './lib/StorableRequest.mjs';\nimport './_version.mjs';\n\n\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\nconst queueNames = new Set();\n\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {onSync, maxRetentionTime} = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', {name});\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'push');\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'unshift');\n }\n\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n } else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n\n return unexpiredEntries;\n }\n\n\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest(\n {request, metadata, timestamp = Date.now()}, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n\n await this._queueStore[`${operation}Entry`](entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n } else {\n await this.registerSync();\n }\n }\n\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n\n return convertEntry(entry);\n }\n }\n\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n } catch (error) {\n await this.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', {name: this._name});\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in registration) {\n try {\n await registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n\n const syncComplete = async () => {\n this._syncInProgress = true;\n\n let syncError;\n try {\n await this._onSync({queue: this});\n } catch (error) {\n syncError = error;\n\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n } finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({queue: this});\n }\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n\n\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\n\nexport {Queue};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Queue} from './Queue.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n async fetchDidFail({request}) {\n await this._queue.pushRequest({request});\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","this","_upgradeDb","entry","id","add","firstEntry","getAllMatching","count","_removeEntry","direction","index","query","IDBKeyRange","only","delete","deleteEntry","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","request","requestData","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","_addRequest","_removeRequest","allEntries","getAll","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","fromRequest","_syncInProgress","_requestsAddedDuringSync","registerSync","shiftRequest","fetch","error","unshiftRequest","registration","sync","register","err","addEventListener","tag","syncComplete","async","syncError","queue","lastChance","waitUntil","queueStoreEntry","queueEntry","queueArgs","_queue","fetchDidFail","bind","pushRequest"],"mappings":"uFAAA,IAAIA,KAAK,kCAAkCC,IAAI,MAAMC,ICarD,MAAMC,EAAa,EACbC,EAAU,0BACVC,EAAoB,WACpBC,EAAe,YAQd,MAAMC,EAQXC,YAAYC,QACLC,EAAaD,OACbE,EAAM,IAAIC,YAAUR,EAASD,EAAY,CAC5CU,gBAAiBC,KAAKC,oBAaVC,UAiBPA,EAAMC,GACbD,EAAMP,UAAYK,KAAKJ,QAEjBI,KAAKH,EAAIO,IAAIb,EAAmBW,sBAYrBA,SAgBVG,SAAoBL,KAAKH,EAAIS,eAAef,EAAmB,CACpEgB,MAAO,IAGLF,EAEFH,EAAMC,GAAKE,EAAWF,GAAK,SAGpBD,EAAMC,GAEfD,EAAMP,UAAYK,KAAKJ,QAEjBI,KAAKH,EAAIO,IAAIb,EAAmBW,2BAU/BF,KAAKQ,EAAa,CAACC,UAAW,mCAU9BT,KAAKQ,EAAa,CAACC,UAAW,qCAWxBT,KAAKH,EAAIS,eAAef,EAAmB,CACtDmB,MAAOlB,EACPmB,MAAOC,YAAYC,KAAKb,KAAKJ,uBAefO,SACVH,KAAKH,EAAIiB,OAAOvB,EAAmBY,YAUxBM,UAACA,UACXP,SAAeF,KAAKH,EAAI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AAU2B,uBAEJA,aAAaC,KAAKC,YAAYvC,KAAcpD,KAAK8D,KACvD,MAAO8B,KAkBbzB,IACM,SAAUsB,aACZvG,KAAK2G,iBAAiB,OAAS7E,OACzBA,EAAM8E,SAAW1C,KAAcpD,KAAK8D,IAAS,OAMzCiC,EAAeC,cAGfC,OAFCf,GAAkB,YAIflF,KAAK+D,EAAQ,CAACmC,MAAOlG,OAC3B,MAAOuF,SACPU,EAAYV,WAWRvF,KAAKmF,GACHc,IAAcjF,EAAMmF,kBAClBnG,KAAKoF,oBAGRF,GAAkB,OAClBC,GAA2B,IAGpCnE,EAAMoF,UAAUL,aASfhC,EAAQ,CAACmC,MAAOlG,6BAahBsD,GAcX,MAAMwB,EAAgBuB,UACdC,EAAa,CACjBvE,QAAS,IAAID,EAAgBuE,EAAgBrE,aAAakB,YAC1D0B,UAAWyB,EAAgBzB,kBAEzByB,EAAgBtB,WAClBuB,EAAWvB,SAAWsB,EAAgBtB,UAEjCuB,6BCrXT,MAME5G,eAAe6G,QACRC,EAAS,IAAIhD,KAAS+C,QACtBE,aAAezG,KAAKyG,aAAaC,KAAK1G,0BAQ1B+B,QAACA,UACZ/B,KAAKwG,EAAOG,YAAY,CAAC5E,QAAAA"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.broadcastUpdate = (function (exports, assert_mjs, getFriendlyURL_mjs, logger_mjs, Deferred_mjs, WorkboxError_mjs) {
'use strict';
try {
self['workbox:broadcast-update:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Given two `Response's`, compares several header values to see if they are
* the same or not.
*
* @param {Response} firstResponse
* @param {Response} secondResponse
* @param {Array<string>} headersToCheck
* @return {boolean}
*
* @memberof workbox.broadcastUpdate
* @private
*/
const responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {
{
if (!(firstResponse instanceof Response && secondResponse instanceof Response)) {
throw new WorkboxError_mjs.WorkboxError('invalid-responses-are-same-args');
}
}
const atLeastOneHeaderAvailable = headersToCheck.some(header => {
return firstResponse.headers.has(header) && secondResponse.headers.has(header);
});
if (!atLeastOneHeaderAvailable) {
{
logger_mjs.logger.warn(`Unable to determine where the response has been updated ` + `because none of the headers that would be checked are present.`);
logger_mjs.logger.debug(`Attempting to compare the following: `, firstResponse, secondResponse, headersToCheck);
} // Just return true, indicating the that responses are the same, since we
// can't determine otherwise.
return true;
}
return headersToCheck.every(header => {
const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header);
const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header);
return headerStateComparison && headerValueComparison;
});
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';
const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';
const DEFAULT_BROADCAST_CHANNEL_NAME = 'workbox';
const DEFAULT_DEFER_NOTIFICATION_TIMEOUT = 10000;
const DEFAULT_HEADERS_TO_CHECK = ['content-length', 'etag', 'last-modified'];
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* You would not normally call this method directly; it's called automatically
* by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here
* for the benefit of developers who would rather not use the full
* `BroadcastCacheUpdate` implementation.
*
* Calling this will dispatch a message on the provided
* {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}
* to notify interested subscribers about a change to a cached resource.
*
* The message that's posted has a formation inspired by the
* [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)
* format like so:
*
* ```
* {
* type: 'CACHE_UPDATED',
* meta: 'workbox-broadcast-update',
* payload: {
* cacheName: 'the-cache-name',
* updatedURL: 'https://example.com/'
* }
* }
* ```
*
* (Usage of [Flux](https://facebook.github.io/flux/) itself is not at
* all required.)
*
* @param {Object} options
* @param {string} options.cacheName The name of the cache in which the updated
* `Response` was stored.
* @param {string} options.url The URL associated with the updated `Response`.
* @param {BroadcastChannel} [options.channel] The `BroadcastChannel` to use.
* If no channel is set or the browser doesn't support the BroadcastChannel
* api, then an attempt will be made to `postMessage` each window client.
*
* @memberof workbox.broadcastUpdate
*/
const broadcastUpdate = async ({
channel,
cacheName,
url
}) => {
{
assert_mjs.assert.isType(cacheName, 'string', {
moduleName: 'workbox-broadcast-update',
className: '~',
funcName: 'broadcastUpdate',
paramName: 'cacheName'
});
assert_mjs.assert.isType(url, 'string', {
moduleName: 'workbox-broadcast-update',
className: '~',
funcName: 'broadcastUpdate',
paramName: 'url'
});
}
const data = {
type: CACHE_UPDATED_MESSAGE_TYPE,
meta: CACHE_UPDATED_MESSAGE_META,
payload: {
cacheName: cacheName,
updatedURL: url
}
};
if (channel) {
channel.postMessage(data);
} else {
const windows = await clients.matchAll({
type: 'window'
});
for (const win of windows) {
win.postMessage(data);
}
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}
* to notify interested parties when a cached response has been updated.
* In browsers that do not support the Broadcast Channel API, the instance
* falls back to sending the update via `postMessage()` to all window clients.
*
* For efficiency's sake, the underlying response bodies are not compared;
* only specific response headers are checked.
*
* @memberof workbox.broadcastUpdate
*/
class BroadcastCacheUpdate {
/**
* Construct a BroadcastCacheUpdate instance with a specific `channelName` to
* broadcast messages on
*
* @param {Object} options
* @param {Array<string>}
* [options.headersToCheck=['content-length', 'etag', 'last-modified']]
* A list of headers that will be used to determine whether the responses
* differ.
* @param {string} [options.channelName='workbox'] The name that will be used
*. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
* channel name used by the `workbox-window` package).
* @param {string} [options.deferNoticationTimeout=10000] The amount of time
* to wait for a ready message from the window on navigation requests
* before sending the update.
*/
constructor({
headersToCheck,
channelName,
deferNoticationTimeout
} = {}) {
this._headersToCheck = headersToCheck || DEFAULT_HEADERS_TO_CHECK;
this._channelName = channelName || DEFAULT_BROADCAST_CHANNEL_NAME;
this._deferNoticationTimeout = deferNoticationTimeout || DEFAULT_DEFER_NOTIFICATION_TIMEOUT;
{
assert_mjs.assert.isType(this._channelName, 'string', {
moduleName: 'workbox-broadcast-update',
className: 'BroadcastCacheUpdate',
funcName: 'constructor',
paramName: 'channelName'
});
assert_mjs.assert.isArray(this._headersToCheck, {
moduleName: 'workbox-broadcast-update',
className: 'BroadcastCacheUpdate',
funcName: 'constructor',
paramName: 'headersToCheck'
});
}
this._initWindowReadyDeferreds();
}
/**
* Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)
* and send a message via the
* {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}
* if they differ.
*
* Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.
*
* @param {Object} options
* @param {Response} options.oldResponse Cached response to compare.
* @param {Response} options.newResponse Possibly updated response to compare.
* @param {string} options.url The URL of the request.
* @param {string} options.cacheName Name of the cache the responses belong
* to. This is included in the broadcast message.
* @param {Event} [options.event] event An optional event that triggered
* this possible cache update.
* @return {Promise} Resolves once the update is sent.
*/
notifyIfUpdated({
oldResponse,
newResponse,
url,
cacheName,
event
}) {
if (!responsesAreSame(oldResponse, newResponse, this._headersToCheck)) {
{
logger_mjs.logger.log(`Newer response found (and cached) for:`, url);
}
const sendUpdate = async () => {
// In the case of a navigation request, the requesting page will likely
// not have loaded its JavaScript in time to recevied the update
// notification, so we defer it until ready (or we timeout waiting).
if (event && event.request && event.request.mode === 'navigate') {
{
logger_mjs.logger.debug(`Original request was a navigation request, ` + `waiting for a ready message from the window`, event.request);
}
await this._windowReadyOrTimeout(event);
}
await this._broadcastUpdate({
channel: this._getChannel(),
cacheName,
url
});
}; // Send the update and ensure the SW stays alive until it's sent.
const done = sendUpdate();
if (event) {
try {
event.waitUntil(done);
} catch (error) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive ` + `when broadcasting cache update for ` + `${getFriendlyURL_mjs.getFriendlyURL(event.request.url)}'.`);
}
}
}
return done;
}
}
/**
* NOTE: this is exposed on the instance primarily so it can be spied on
* in tests.
*
* @param {Object} opts
* @private
*/
async _broadcastUpdate(opts) {
await broadcastUpdate(opts);
}
/**
* @return {BroadcastChannel|undefined} The BroadcastChannel instance used for
* broadcasting updates, or undefined if the browser doesn't support the
* Broadcast Channel API.
*
* @private
*/
_getChannel() {
if ('BroadcastChannel' in self && !this._channel) {
this._channel = new BroadcastChannel(this._channelName);
}
return this._channel;
}
/**
* Waits for a message from the window indicating that it's capable of
* receiving broadcasts. By default, this will only wait for the amount of
* time specified via the `deferNoticationTimeout` option.
*
* @param {Event} event The navigation fetch event.
* @return {Promise}
* @private
*/
_windowReadyOrTimeout(event) {
if (!this._navigationEventsDeferreds.has(event)) {
const deferred = new Deferred_mjs.Deferred(); // Set the deferred on the `_navigationEventsDeferreds` map so it will
// be resolved when the next ready message event comes.
this._navigationEventsDeferreds.set(event, deferred); // But don't wait too long for the message since it may never come.
const timeout = setTimeout(() => {
{
logger_mjs.logger.debug(`Timed out after ${this._deferNoticationTimeout}` + `ms waiting for message from window`);
}
deferred.resolve();
}, this._deferNoticationTimeout); // Ensure the timeout is cleared if the deferred promise is resolved.
deferred.promise.then(() => clearTimeout(timeout));
}
return this._navigationEventsDeferreds.get(event).promise;
}
/**
* Creates a mapping between navigation fetch events and deferreds, and adds
* a listener for message events from the window. When message events arrive,
* all deferreds in the mapping are resolved.
*
* Note: it would be easier if we could only resolve the deferred of
* navigation fetch event whose client ID matched the source ID of the
* message event, but currently client IDs are not exposed on navigation
* fetch events: https://www.chromestatus.com/feature/4846038800138240
*
* @private
*/
_initWindowReadyDeferreds() {
// A mapping between navigation events and their deferreds.
this._navigationEventsDeferreds = new Map(); // The message listener needs to be added in the initial run of the
// service worker, but since we don't actually need to be listening for
// messages until the cache updates, we only invoke the callback if set.
self.addEventListener('message', event => {
if (event.data.type === 'WINDOW_READY' && event.data.meta === 'workbox-window' && this._navigationEventsDeferreds.size > 0) {
{
logger_mjs.logger.debug(`Received WINDOW_READY event: `, event);
} // Resolve any pending deferreds.
for (const deferred of this._navigationEventsDeferreds.values()) {
deferred.resolve();
}
this._navigationEventsDeferreds.clear();
}
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This plugin will automatically broadcast a message whenever a cached response
* is updated.
*
* @memberof workbox.broadcastUpdate
*/
class Plugin {
/**
* Construct a BroadcastCacheUpdate instance with the passed options and
* calls its `notifyIfUpdated()` method whenever the plugin's
* `cacheDidUpdate` callback is invoked.
*
* @param {Object} options
* @param {Array<string>}
* [options.headersToCheck=['content-length', 'etag', 'last-modified']]
* A list of headers that will be used to determine whether the responses
* differ.
* @param {string} [options.channelName='workbox'] The name that will be used
*. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
* channel name used by the `workbox-window` package).
* @param {string} [options.deferNoticationTimeout=10000] The amount of time
* to wait for a ready message from the window on navigation requests
* before sending the update.
*/
constructor(options) {
this._broadcastUpdate = new BroadcastCacheUpdate(options);
}
/**
* A "lifecycle" callback that will be triggered automatically by the
* `workbox-sw` and `workbox-runtime-caching` handlers when an entry is
* added to a cache.
*
* @private
* @param {Object} options The input object to this function.
* @param {string} options.cacheName Name of the cache being updated.
* @param {Response} [options.oldResponse] The previous cached value, if any.
* @param {Response} options.newResponse The new value in the cache.
* @param {Request} options.request The request that triggered the udpate.
* @param {Request} [options.event] The event that triggered the update.
*/
cacheDidUpdate({
cacheName,
oldResponse,
newResponse,
request,
event
}) {
{
assert_mjs.assert.isType(cacheName, 'string', {
moduleName: 'workbox-broadcast-update',
className: 'Plugin',
funcName: 'cacheDidUpdate',
paramName: 'cacheName'
});
assert_mjs.assert.isInstance(newResponse, Response, {
moduleName: 'workbox-broadcast-update',
className: 'Plugin',
funcName: 'cacheDidUpdate',
paramName: 'newResponse'
});
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-broadcast-update',
className: 'Plugin',
funcName: 'cacheDidUpdate',
paramName: 'request'
});
}
if (!oldResponse) {
// Without a two responses there is nothing to compare.
return;
}
this._broadcastUpdate.notifyIfUpdated({
cacheName,
oldResponse,
newResponse,
event,
url: request.url
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.BroadcastCacheUpdate = BroadcastCacheUpdate;
exports.Plugin = Plugin;
exports.broadcastUpdate = broadcastUpdate;
exports.responsesAreSame = responsesAreSame;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-broadcast-update.dev.js.map
{"version":3,"file":"workbox-broadcast-update.dev.js","sources":["../_version.mjs","../responsesAreSame.mjs","../utils/constants.mjs","../broadcastUpdate.mjs","../BroadcastCacheUpdate.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:broadcast-update:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport './_version.mjs';\n\n/**\n * Given two `Response's`, compares several header values to see if they are\n * the same or not.\n *\n * @param {Response} firstResponse\n * @param {Response} secondResponse\n * @param {Array<string>} headersToCheck\n * @return {boolean}\n *\n * @memberof workbox.broadcastUpdate\n * @private\n */\nconst responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {\n if (process.env.NODE_ENV !== 'production') {\n if (!(firstResponse instanceof Response &&\n secondResponse instanceof Response)) {\n throw new WorkboxError('invalid-responses-are-same-args');\n }\n }\n\n const atLeastOneHeaderAvailable = headersToCheck.some((header) => {\n return firstResponse.headers.has(header) &&\n secondResponse.headers.has(header);\n });\n\n if (!atLeastOneHeaderAvailable) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to determine where the response has been updated ` +\n `because none of the headers that would be checked are present.`);\n logger.debug(`Attempting to compare the following: `,\n firstResponse, secondResponse, headersToCheck);\n }\n\n // Just return true, indicating the that responses are the same, since we\n // can't determine otherwise.\n return true;\n }\n\n return headersToCheck.every((header) => {\n const headerStateComparison = firstResponse.headers.has(header) ===\n secondResponse.headers.has(header);\n const headerValueComparison = firstResponse.headers.get(header) ===\n secondResponse.headers.get(header);\n\n return headerStateComparison && headerValueComparison;\n });\n};\n\nexport {responsesAreSame};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';\nexport const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';\nexport const DEFAULT_BROADCAST_CHANNEL_NAME = 'workbox';\nexport const DEFAULT_DEFER_NOTIFICATION_TIMEOUT = 10000;\nexport const DEFAULT_HEADERS_TO_CHECK = [\n 'content-length',\n 'etag',\n 'last-modified',\n];\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {CACHE_UPDATED_MESSAGE_TYPE, CACHE_UPDATED_MESSAGE_META}\n from './utils/constants.mjs';\n\nimport './_version.mjs';\n\n/**\n * You would not normally call this method directly; it's called automatically\n * by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here\n * for the benefit of developers who would rather not use the full\n * `BroadcastCacheUpdate` implementation.\n *\n * Calling this will dispatch a message on the provided\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}\n * to notify interested subscribers about a change to a cached resource.\n *\n * The message that's posted has a formation inspired by the\n * [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)\n * format like so:\n *\n * ```\n * {\n * type: 'CACHE_UPDATED',\n * meta: 'workbox-broadcast-update',\n * payload: {\n * cacheName: 'the-cache-name',\n * updatedURL: 'https://example.com/'\n * }\n * }\n * ```\n *\n * (Usage of [Flux](https://facebook.github.io/flux/) itself is not at\n * all required.)\n *\n * @param {Object} options\n * @param {string} options.cacheName The name of the cache in which the updated\n * `Response` was stored.\n * @param {string} options.url The URL associated with the updated `Response`.\n * @param {BroadcastChannel} [options.channel] The `BroadcastChannel` to use.\n * If no channel is set or the browser doesn't support the BroadcastChannel\n * api, then an attempt will be made to `postMessage` each window client.\n *\n * @memberof workbox.broadcastUpdate\n */\nconst broadcastUpdate = async ({channel, cacheName, url}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'cacheName',\n });\n assert.isType(url, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'url',\n });\n }\n\n const data = {\n type: CACHE_UPDATED_MESSAGE_TYPE,\n meta: CACHE_UPDATED_MESSAGE_META,\n payload: {\n cacheName: cacheName,\n updatedURL: url,\n },\n };\n\n if (channel) {\n channel.postMessage(data);\n } else {\n const windows = await clients.matchAll({type: 'window'});\n for (const win of windows) {\n win.postMessage(data);\n }\n }\n};\n\nexport {broadcastUpdate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {responsesAreSame} from './responsesAreSame.mjs';\nimport {broadcastUpdate} from './broadcastUpdate.mjs';\n\nimport {DEFAULT_HEADERS_TO_CHECK, DEFAULT_BROADCAST_CHANNEL_NAME,\n DEFAULT_DEFER_NOTIFICATION_TIMEOUT} from './utils/constants.mjs';\n\nimport './_version.mjs';\n\n/**\n * Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}\n * to notify interested parties when a cached response has been updated.\n * In browsers that do not support the Broadcast Channel API, the instance\n * falls back to sending the update via `postMessage()` to all window clients.\n *\n * For efficiency's sake, the underlying response bodies are not compared;\n * only specific response headers are checked.\n *\n * @memberof workbox.broadcastUpdate\n */\nclass BroadcastCacheUpdate {\n /**\n * Construct a BroadcastCacheUpdate instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']]\n * A list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.channelName='workbox'] The name that will be used\n *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the\n * channel name used by the `workbox-window` package).\n * @param {string} [options.deferNoticationTimeout=10000] The amount of time\n * to wait for a ready message from the window on navigation requests\n * before sending the update.\n */\n constructor({headersToCheck, channelName, deferNoticationTimeout} = {}) {\n this._headersToCheck = headersToCheck || DEFAULT_HEADERS_TO_CHECK;\n this._channelName = channelName || DEFAULT_BROADCAST_CHANNEL_NAME;\n this._deferNoticationTimeout =\n deferNoticationTimeout || DEFAULT_DEFER_NOTIFICATION_TIMEOUT;\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(this._channelName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: 'BroadcastCacheUpdate',\n funcName: 'constructor',\n paramName: 'channelName',\n });\n assert.isArray(this._headersToCheck, {\n moduleName: 'workbox-broadcast-update',\n className: 'BroadcastCacheUpdate',\n funcName: 'constructor',\n paramName: 'headersToCheck',\n });\n }\n\n this._initWindowReadyDeferreds();\n }\n\n /**\n * Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * and send a message via the\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}\n * if they differ.\n *\n * Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.\n *\n * @param {Object} options\n * @param {Response} options.oldResponse Cached response to compare.\n * @param {Response} options.newResponse Possibly updated response to compare.\n * @param {string} options.url The URL of the request.\n * @param {string} options.cacheName Name of the cache the responses belong\n * to. This is included in the broadcast message.\n * @param {Event} [options.event] event An optional event that triggered\n * this possible cache update.\n * @return {Promise} Resolves once the update is sent.\n */\n notifyIfUpdated({oldResponse, newResponse, url, cacheName, event}) {\n if (!responsesAreSame(oldResponse, newResponse, this._headersToCheck)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Newer response found (and cached) for:`, url);\n }\n\n const sendUpdate = async () => {\n // In the case of a navigation request, the requesting page will likely\n // not have loaded its JavaScript in time to recevied the update\n // notification, so we defer it until ready (or we timeout waiting).\n if (event && event.request && event.request.mode === 'navigate') {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Original request was a navigation request, ` +\n `waiting for a ready message from the window`, event.request);\n }\n await this._windowReadyOrTimeout(event);\n }\n await this._broadcastUpdate({\n channel: this._getChannel(),\n cacheName,\n url,\n });\n };\n\n // Send the update and ensure the SW stays alive until it's sent.\n const done = sendUpdate();\n\n if (event) {\n try {\n event.waitUntil(done);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive ` +\n `when broadcasting cache update for ` +\n `${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n return done;\n }\n }\n\n /**\n * NOTE: this is exposed on the instance primarily so it can be spied on\n * in tests.\n *\n * @param {Object} opts\n * @private\n */\n async _broadcastUpdate(opts) {\n await broadcastUpdate(opts);\n }\n\n /**\n * @return {BroadcastChannel|undefined} The BroadcastChannel instance used for\n * broadcasting updates, or undefined if the browser doesn't support the\n * Broadcast Channel API.\n *\n * @private\n */\n _getChannel() {\n if (('BroadcastChannel' in self) && !this._channel) {\n this._channel = new BroadcastChannel(this._channelName);\n }\n return this._channel;\n }\n\n /**\n * Waits for a message from the window indicating that it's capable of\n * receiving broadcasts. By default, this will only wait for the amount of\n * time specified via the `deferNoticationTimeout` option.\n *\n * @param {Event} event The navigation fetch event.\n * @return {Promise}\n * @private\n */\n _windowReadyOrTimeout(event) {\n if (!this._navigationEventsDeferreds.has(event)) {\n const deferred = new Deferred();\n\n // Set the deferred on the `_navigationEventsDeferreds` map so it will\n // be resolved when the next ready message event comes.\n this._navigationEventsDeferreds.set(event, deferred);\n\n // But don't wait too long for the message since it may never come.\n const timeout = setTimeout(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Timed out after ${this._deferNoticationTimeout}` +\n `ms waiting for message from window`);\n }\n deferred.resolve();\n }, this._deferNoticationTimeout);\n\n // Ensure the timeout is cleared if the deferred promise is resolved.\n deferred.promise.then(() => clearTimeout(timeout));\n }\n return this._navigationEventsDeferreds.get(event).promise;\n }\n\n /**\n * Creates a mapping between navigation fetch events and deferreds, and adds\n * a listener for message events from the window. When message events arrive,\n * all deferreds in the mapping are resolved.\n *\n * Note: it would be easier if we could only resolve the deferred of\n * navigation fetch event whose client ID matched the source ID of the\n * message event, but currently client IDs are not exposed on navigation\n * fetch events: https://www.chromestatus.com/feature/4846038800138240\n *\n * @private\n */\n _initWindowReadyDeferreds() {\n // A mapping between navigation events and their deferreds.\n this._navigationEventsDeferreds = new Map();\n\n // The message listener needs to be added in the initial run of the\n // service worker, but since we don't actually need to be listening for\n // messages until the cache updates, we only invoke the callback if set.\n self.addEventListener('message', (event) => {\n if (event.data.type === 'WINDOW_READY' &&\n event.data.meta === 'workbox-window' &&\n this._navigationEventsDeferreds.size > 0) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Received WINDOW_READY event: `, event);\n }\n // Resolve any pending deferreds.\n for (const deferred of this._navigationEventsDeferreds.values()) {\n deferred.resolve();\n }\n this._navigationEventsDeferreds.clear();\n }\n });\n }\n}\n\nexport {BroadcastCacheUpdate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {BroadcastCacheUpdate} from './BroadcastCacheUpdate.mjs';\nimport './_version.mjs';\n\n/**\n * This plugin will automatically broadcast a message whenever a cached response\n * is updated.\n *\n * @memberof workbox.broadcastUpdate\n */\nclass Plugin {\n /**\n * Construct a BroadcastCacheUpdate instance with the passed options and\n * calls its `notifyIfUpdated()` method whenever the plugin's\n * `cacheDidUpdate` callback is invoked.\n *\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']]\n * A list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.channelName='workbox'] The name that will be used\n *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the\n * channel name used by the `workbox-window` package).\n * @param {string} [options.deferNoticationTimeout=10000] The amount of time\n * to wait for a ready message from the window on navigation requests\n * before sending the update.\n */\n constructor(options) {\n this._broadcastUpdate = new BroadcastCacheUpdate(options);\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is\n * added to a cache.\n *\n * @private\n * @param {Object} options The input object to this function.\n * @param {string} options.cacheName Name of the cache being updated.\n * @param {Response} [options.oldResponse] The previous cached value, if any.\n * @param {Response} options.newResponse The new value in the cache.\n * @param {Request} options.request The request that triggered the udpate.\n * @param {Request} [options.event] The event that triggered the update.\n */\n cacheDidUpdate({cacheName, oldResponse, newResponse, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(newResponse, Response, {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'newResponse',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n if (!oldResponse) {\n // Without a two responses there is nothing to compare.\n return;\n }\n this._broadcastUpdate.notifyIfUpdated({\n cacheName,\n oldResponse,\n newResponse,\n event,\n url: request.url,\n });\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {BroadcastCacheUpdate} from './BroadcastCacheUpdate.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport {broadcastUpdate} from './broadcastUpdate.mjs';\nimport {responsesAreSame} from './responsesAreSame.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.broadcastUpdate\n */\n\nexport {\n BroadcastCacheUpdate,\n Plugin,\n broadcastUpdate,\n responsesAreSame,\n};\n"],"names":["self","_","e","responsesAreSame","firstResponse","secondResponse","headersToCheck","Response","WorkboxError","atLeastOneHeaderAvailable","some","header","headers","has","logger","warn","debug","every","headerStateComparison","headerValueComparison","get","CACHE_UPDATED_MESSAGE_TYPE","CACHE_UPDATED_MESSAGE_META","DEFAULT_BROADCAST_CHANNEL_NAME","DEFAULT_DEFER_NOTIFICATION_TIMEOUT","DEFAULT_HEADERS_TO_CHECK","broadcastUpdate","channel","cacheName","url","assert","isType","moduleName","className","funcName","paramName","data","type","meta","payload","updatedURL","postMessage","windows","clients","matchAll","win","BroadcastCacheUpdate","constructor","channelName","deferNoticationTimeout","_headersToCheck","_channelName","_deferNoticationTimeout","isArray","_initWindowReadyDeferreds","notifyIfUpdated","oldResponse","newResponse","event","log","sendUpdate","request","mode","_windowReadyOrTimeout","_broadcastUpdate","_getChannel","done","waitUntil","error","getFriendlyURL","opts","_channel","BroadcastChannel","_navigationEventsDeferreds","deferred","Deferred","set","timeout","setTimeout","resolve","promise","then","clearTimeout","Map","addEventListener","size","values","clear","Plugin","options","cacheDidUpdate","isInstance","Request"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,gCAAD,CAAJ,IAAwCC,CAAC,EAAzC;EAA4C,CAAhD,CAAgD,OAAMC,CAAN,EAAQ;;ECAxD;;;;;;;AAQA,EAIA;;;;;;;;;;;;;AAYA,QAAMC,gBAAgB,GAAG,CAACC,aAAD,EAAgBC,cAAhB,EAAgCC,cAAhC,KAAmD;EAC1E,EAA2C;EACzC,QAAI,EAAEF,aAAa,YAAYG,QAAzB,IACJF,cAAc,YAAYE,QADxB,CAAJ,EACuC;EACrC,YAAM,IAAIC,6BAAJ,CAAiB,iCAAjB,CAAN;EACD;EACF;;EAED,QAAMC,yBAAyB,GAAGH,cAAc,CAACI,IAAf,CAAqBC,MAAD,IAAY;EAChE,WAAOP,aAAa,CAACQ,OAAd,CAAsBC,GAAtB,CAA0BF,MAA1B,KACLN,cAAc,CAACO,OAAf,CAAuBC,GAAvB,CAA2BF,MAA3B,CADF;EAED,GAHiC,CAAlC;;EAKA,MAAI,CAACF,yBAAL,EAAgC;EAC9B,IAA2C;EACzCK,MAAAA,iBAAM,CAACC,IAAP,CAAa,0DAAD,GACT,gEADH;EAEAD,MAAAA,iBAAM,CAACE,KAAP,CAAc,uCAAd,EACIZ,aADJ,EACmBC,cADnB,EACmCC,cADnC;EAED,KAN6B;EAS9B;;;EACA,WAAO,IAAP;EACD;;EAED,SAAOA,cAAc,CAACW,KAAf,CAAsBN,MAAD,IAAY;EACtC,UAAMO,qBAAqB,GAAGd,aAAa,CAACQ,OAAd,CAAsBC,GAAtB,CAA0BF,MAA1B,MAC5BN,cAAc,CAACO,OAAf,CAAuBC,GAAvB,CAA2BF,MAA3B,CADF;EAEA,UAAMQ,qBAAqB,GAAGf,aAAa,CAACQ,OAAd,CAAsB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AA3B,EAAoC;EAClC5D,QAAAA,UAAU,EAAE,0BADsB;EAElCC,QAAAA,SAAS,EAAE,QAFuB;EAGlCC,QAAAA,QAAQ,EAAE,gBAHwB;EAIlCC,QAAAA,SAAS,EAAE;EAJuB,OAApC;EAMD;;EAED,QAAI,CAACqB,WAAL,EAAkB;EAChB;EACA;EACD;;EACD,SAAKQ,gBAAL,CAAsBT,eAAtB,CAAsC;EACpC3B,MAAAA,SADoC;EAEpC4B,MAAAA,WAFoC;EAGpCC,MAAAA,WAHoC;EAIpCC,MAAAA,KAJoC;EAKpC7B,MAAAA,GAAG,EAAEgC,OAAO,CAAChC;EALuB,KAAtC;EAOD;;EApEU;;EClBb;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(e,t){"use strict";try{self["workbox:broadcast-update:4.3.1"]&&_()}catch(e){}const s=(e,t,s)=>{return!s.some(s=>e.headers.has(s)&&t.headers.has(s))||s.every(s=>{const n=e.headers.has(s)===t.headers.has(s),a=e.headers.get(s)===t.headers.get(s);return n&&a})},n="workbox",a=1e4,i=["content-length","etag","last-modified"],o=async({channel:e,cacheName:t,url:s})=>{const n={type:"CACHE_UPDATED",meta:"workbox-broadcast-update",payload:{cacheName:t,updatedURL:s}};if(e)e.postMessage(n);else{const e=await clients.matchAll({type:"window"});for(const t of e)t.postMessage(n)}};class c{constructor({headersToCheck:e,channelName:t,deferNoticationTimeout:s}={}){this.t=e||i,this.s=t||n,this.i=s||a,this.o()}notifyIfUpdated({oldResponse:e,newResponse:t,url:n,cacheName:a,event:i}){if(!s(e,t,this.t)){const e=(async()=>{i&&i.request&&"navigate"===i.request.mode&&await this.h(i),await this.l({channel:this.u(),cacheName:a,url:n})})();if(i)try{i.waitUntil(e)}catch(e){}return e}}async l(e){await o(e)}u(){return"BroadcastChannel"in self&&!this.p&&(this.p=new BroadcastChannel(this.s)),this.p}h(e){if(!this.m.has(e)){const s=new t.Deferred;this.m.set(e,s);const n=setTimeout(()=>{s.resolve()},this.i);s.promise.then(()=>clearTimeout(n))}return this.m.get(e).promise}o(){this.m=new Map,self.addEventListener("message",e=>{if("WINDOW_READY"===e.data.type&&"workbox-window"===e.data.meta&&this.m.size>0){for(const e of this.m.values())e.resolve();this.m.clear()}})}}return e.BroadcastCacheUpdate=c,e.Plugin=class{constructor(e){this.l=new c(e)}cacheDidUpdate({cacheName:e,oldResponse:t,newResponse:s,request:n,event:a}){t&&this.l.notifyIfUpdated({cacheName:e,oldResponse:t,newResponse:s,event:a,url:n.url})}},e.broadcastUpdate=o,e.responsesAreSame=s,e}({},workbox.core._private);
//# sourceMappingURL=workbox-broadcast-update.prod.js.map
{"version":3,"file":"workbox-broadcast-update.prod.js","sources":["../_version.mjs","../responsesAreSame.mjs","../utils/constants.mjs","../broadcastUpdate.mjs","../BroadcastCacheUpdate.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:broadcast-update:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport './_version.mjs';\n\n/**\n * Given two `Response's`, compares several header values to see if they are\n * the same or not.\n *\n * @param {Response} firstResponse\n * @param {Response} secondResponse\n * @param {Array<string>} headersToCheck\n * @return {boolean}\n *\n * @memberof workbox.broadcastUpdate\n * @private\n */\nconst responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {\n if (process.env.NODE_ENV !== 'production') {\n if (!(firstResponse instanceof Response &&\n secondResponse instanceof Response)) {\n throw new WorkboxError('invalid-responses-are-same-args');\n }\n }\n\n const atLeastOneHeaderAvailable = headersToCheck.some((header) => {\n return firstResponse.headers.has(header) &&\n secondResponse.headers.has(header);\n });\n\n if (!atLeastOneHeaderAvailable) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to determine where the response has been updated ` +\n `because none of the headers that would be checked are present.`);\n logger.debug(`Attempting to compare the following: `,\n firstResponse, secondResponse, headersToCheck);\n }\n\n // Just return true, indicating the that responses are the same, since we\n // can't determine otherwise.\n return true;\n }\n\n return headersToCheck.every((header) => {\n const headerStateComparison = firstResponse.headers.has(header) ===\n secondResponse.headers.has(header);\n const headerValueComparison = firstResponse.headers.get(header) ===\n secondResponse.headers.get(header);\n\n return headerStateComparison && headerValueComparison;\n });\n};\n\nexport {responsesAreSame};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';\nexport const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';\nexport const DEFAULT_BROADCAST_CHANNEL_NAME = 'workbox';\nexport const DEFAULT_DEFER_NOTIFICATION_TIMEOUT = 10000;\nexport const DEFAULT_HEADERS_TO_CHECK = [\n 'content-length',\n 'etag',\n 'last-modified',\n];\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {CACHE_UPDATED_MESSAGE_TYPE, CACHE_UPDATED_MESSAGE_META}\n from './utils/constants.mjs';\n\nimport './_version.mjs';\n\n/**\n * You would not normally call this method directly; it's called automatically\n * by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here\n * for the benefit of developers who would rather not use the full\n * `BroadcastCacheUpdate` implementation.\n *\n * Calling this will dispatch a message on the provided\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}\n * to notify interested subscribers about a change to a cached resource.\n *\n * The message that's posted has a formation inspired by the\n * [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)\n * format like so:\n *\n * ```\n * {\n * type: 'CACHE_UPDATED',\n * meta: 'workbox-broadcast-update',\n * payload: {\n * cacheName: 'the-cache-name',\n * updatedURL: 'https://example.com/'\n * }\n * }\n * ```\n *\n * (Usage of [Flux](https://facebook.github.io/flux/) itself is not at\n * all required.)\n *\n * @param {Object} options\n * @param {string} options.cacheName The name of the cache in which the updated\n * `Response` was stored.\n * @param {string} options.url The URL associated with the updated `Response`.\n * @param {BroadcastChannel} [options.channel] The `BroadcastChannel` to use.\n * If no channel is set or the browser doesn't support the BroadcastChannel\n * api, then an attempt will be made to `postMessage` each window client.\n *\n * @memberof workbox.broadcastUpdate\n */\nconst broadcastUpdate = async ({channel, cacheName, url}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'cacheName',\n });\n assert.isType(url, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: '~',\n funcName: 'broadcastUpdate',\n paramName: 'url',\n });\n }\n\n const data = {\n type: CACHE_UPDATED_MESSAGE_TYPE,\n meta: CACHE_UPDATED_MESSAGE_META,\n payload: {\n cacheName: cacheName,\n updatedURL: url,\n },\n };\n\n if (channel) {\n channel.postMessage(data);\n } else {\n const windows = await clients.matchAll({type: 'window'});\n for (const win of windows) {\n win.postMessage(data);\n }\n }\n};\n\nexport {broadcastUpdate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {responsesAreSame} from './responsesAreSame.mjs';\nimport {broadcastUpdate} from './broadcastUpdate.mjs';\n\nimport {DEFAULT_HEADERS_TO_CHECK, DEFAULT_BROADCAST_CHANNEL_NAME,\n DEFAULT_DEFER_NOTIFICATION_TIMEOUT} from './utils/constants.mjs';\n\nimport './_version.mjs';\n\n/**\n * Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}\n * to notify interested parties when a cached response has been updated.\n * In browsers that do not support the Broadcast Channel API, the instance\n * falls back to sending the update via `postMessage()` to all window clients.\n *\n * For efficiency's sake, the underlying response bodies are not compared;\n * only specific response headers are checked.\n *\n * @memberof workbox.broadcastUpdate\n */\nclass BroadcastCacheUpdate {\n /**\n * Construct a BroadcastCacheUpdate instance with a specific `channelName` to\n * broadcast messages on\n *\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']]\n * A list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.channelName='workbox'] The name that will be used\n *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the\n * channel name used by the `workbox-window` package).\n * @param {string} [options.deferNoticationTimeout=10000] The amount of time\n * to wait for a ready message from the window on navigation requests\n * before sending the update.\n */\n constructor({headersToCheck, channelName, deferNoticationTimeout} = {}) {\n this._headersToCheck = headersToCheck || DEFAULT_HEADERS_TO_CHECK;\n this._channelName = channelName || DEFAULT_BROADCAST_CHANNEL_NAME;\n this._deferNoticationTimeout =\n deferNoticationTimeout || DEFAULT_DEFER_NOTIFICATION_TIMEOUT;\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(this._channelName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: 'BroadcastCacheUpdate',\n funcName: 'constructor',\n paramName: 'channelName',\n });\n assert.isArray(this._headersToCheck, {\n moduleName: 'workbox-broadcast-update',\n className: 'BroadcastCacheUpdate',\n funcName: 'constructor',\n paramName: 'headersToCheck',\n });\n }\n\n this._initWindowReadyDeferreds();\n }\n\n /**\n * Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * and send a message via the\n * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}\n * if they differ.\n *\n * Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.\n *\n * @param {Object} options\n * @param {Response} options.oldResponse Cached response to compare.\n * @param {Response} options.newResponse Possibly updated response to compare.\n * @param {string} options.url The URL of the request.\n * @param {string} options.cacheName Name of the cache the responses belong\n * to. This is included in the broadcast message.\n * @param {Event} [options.event] event An optional event that triggered\n * this possible cache update.\n * @return {Promise} Resolves once the update is sent.\n */\n notifyIfUpdated({oldResponse, newResponse, url, cacheName, event}) {\n if (!responsesAreSame(oldResponse, newResponse, this._headersToCheck)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Newer response found (and cached) for:`, url);\n }\n\n const sendUpdate = async () => {\n // In the case of a navigation request, the requesting page will likely\n // not have loaded its JavaScript in time to recevied the update\n // notification, so we defer it until ready (or we timeout waiting).\n if (event && event.request && event.request.mode === 'navigate') {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Original request was a navigation request, ` +\n `waiting for a ready message from the window`, event.request);\n }\n await this._windowReadyOrTimeout(event);\n }\n await this._broadcastUpdate({\n channel: this._getChannel(),\n cacheName,\n url,\n });\n };\n\n // Send the update and ensure the SW stays alive until it's sent.\n const done = sendUpdate();\n\n if (event) {\n try {\n event.waitUntil(done);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive ` +\n `when broadcasting cache update for ` +\n `${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n return done;\n }\n }\n\n /**\n * NOTE: this is exposed on the instance primarily so it can be spied on\n * in tests.\n *\n * @param {Object} opts\n * @private\n */\n async _broadcastUpdate(opts) {\n await broadcastUpdate(opts);\n }\n\n /**\n * @return {BroadcastChannel|undefined} The BroadcastChannel instance used for\n * broadcasting updates, or undefined if the browser doesn't support the\n * Broadcast Channel API.\n *\n * @private\n */\n _getChannel() {\n if (('BroadcastChannel' in self) && !this._channel) {\n this._channel = new BroadcastChannel(this._channelName);\n }\n return this._channel;\n }\n\n /**\n * Waits for a message from the window indicating that it's capable of\n * receiving broadcasts. By default, this will only wait for the amount of\n * time specified via the `deferNoticationTimeout` option.\n *\n * @param {Event} event The navigation fetch event.\n * @return {Promise}\n * @private\n */\n _windowReadyOrTimeout(event) {\n if (!this._navigationEventsDeferreds.has(event)) {\n const deferred = new Deferred();\n\n // Set the deferred on the `_navigationEventsDeferreds` map so it will\n // be resolved when the next ready message event comes.\n this._navigationEventsDeferreds.set(event, deferred);\n\n // But don't wait too long for the message since it may never come.\n const timeout = setTimeout(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Timed out after ${this._deferNoticationTimeout}` +\n `ms waiting for message from window`);\n }\n deferred.resolve();\n }, this._deferNoticationTimeout);\n\n // Ensure the timeout is cleared if the deferred promise is resolved.\n deferred.promise.then(() => clearTimeout(timeout));\n }\n return this._navigationEventsDeferreds.get(event).promise;\n }\n\n /**\n * Creates a mapping between navigation fetch events and deferreds, and adds\n * a listener for message events from the window. When message events arrive,\n * all deferreds in the mapping are resolved.\n *\n * Note: it would be easier if we could only resolve the deferred of\n * navigation fetch event whose client ID matched the source ID of the\n * message event, but currently client IDs are not exposed on navigation\n * fetch events: https://www.chromestatus.com/feature/4846038800138240\n *\n * @private\n */\n _initWindowReadyDeferreds() {\n // A mapping between navigation events and their deferreds.\n this._navigationEventsDeferreds = new Map();\n\n // The message listener needs to be added in the initial run of the\n // service worker, but since we don't actually need to be listening for\n // messages until the cache updates, we only invoke the callback if set.\n self.addEventListener('message', (event) => {\n if (event.data.type === 'WINDOW_READY' &&\n event.data.meta === 'workbox-window' &&\n this._navigationEventsDeferreds.size > 0) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Received WINDOW_READY event: `, event);\n }\n // Resolve any pending deferreds.\n for (const deferred of this._navigationEventsDeferreds.values()) {\n deferred.resolve();\n }\n this._navigationEventsDeferreds.clear();\n }\n });\n }\n}\n\nexport {BroadcastCacheUpdate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {BroadcastCacheUpdate} from './BroadcastCacheUpdate.mjs';\nimport './_version.mjs';\n\n/**\n * This plugin will automatically broadcast a message whenever a cached response\n * is updated.\n *\n * @memberof workbox.broadcastUpdate\n */\nclass Plugin {\n /**\n * Construct a BroadcastCacheUpdate instance with the passed options and\n * calls its `notifyIfUpdated()` method whenever the plugin's\n * `cacheDidUpdate` callback is invoked.\n *\n * @param {Object} options\n * @param {Array<string>}\n * [options.headersToCheck=['content-length', 'etag', 'last-modified']]\n * A list of headers that will be used to determine whether the responses\n * differ.\n * @param {string} [options.channelName='workbox'] The name that will be used\n *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the\n * channel name used by the `workbox-window` package).\n * @param {string} [options.deferNoticationTimeout=10000] The amount of time\n * to wait for a ready message from the window on navigation requests\n * before sending the update.\n */\n constructor(options) {\n this._broadcastUpdate = new BroadcastCacheUpdate(options);\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is\n * added to a cache.\n *\n * @private\n * @param {Object} options The input object to this function.\n * @param {string} options.cacheName Name of the cache being updated.\n * @param {Response} [options.oldResponse] The previous cached value, if any.\n * @param {Response} options.newResponse The new value in the cache.\n * @param {Request} options.request The request that triggered the udpate.\n * @param {Request} [options.event] The event that triggered the update.\n */\n cacheDidUpdate({cacheName, oldResponse, newResponse, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(newResponse, Response, {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'newResponse',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-broadcast-update',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n if (!oldResponse) {\n // Without a two responses there is nothing to compare.\n return;\n }\n this._broadcastUpdate.notifyIfUpdated({\n cacheName,\n oldResponse,\n newResponse,\n event,\n url: request.url,\n });\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","responsesAreSame","firstResponse","secondResponse","headersToCheck","some","header","headers","has","every","headerStateComparison","headerValueComparison","get","DEFAULT_BROADCAST_CHANNEL_NAME","DEFAULT_DEFER_NOTIFICATION_TIMEOUT","DEFAULT_HEADERS_TO_CHECK","broadcastUpdate","async","channel","cacheName","url","data","type","meta","payload","updatedURL","postMessage","windows","clients","matchAll","win","BroadcastCacheUpdate","constructor","channelName","deferNoticationTimeout","_headersToCheck","_channelName","_deferNoticationTimeout","_initWindowReadyDeferreds","notifyIfUpdated","oldResponse","newResponse","event","this","done","request","mode","_windowReadyOrTimeout","_broadcastUpdate","_getChannel","sendUpdate","waitUntil","error","opts","_channel","BroadcastChannel","_navigationEventsDeferreds","deferred","Deferred","set","timeout","setTimeout","resolve","promise","then","clearTimeout","Map","addEventListener","size","values","clear","options","cacheDidUpdate"],"mappings":"sFAAA,IAAIA,KAAK,mCAAmCC,IAAI,MAAMC,UCwBhDC,EAAmB,CAACC,EAAeC,EAAgBC,YAQrBA,EAAeC,KAAMC,GAC9CJ,EAAcK,QAAQC,IAAIF,IAC/BH,EAAeI,QAAQC,IAAIF,KAgBxBF,EAAeK,MAAOH,UACrBI,EAAwBR,EAAcK,QAAQC,IAAIF,KACtDH,EAAeI,QAAQC,IAAIF,GACvBK,EAAwBT,EAAcK,QAAQK,IAAIN,KACtDH,EAAeI,QAAQK,IAAIN,UAEtBI,GAAyBC,KC5CvBE,EAAiC,UACjCC,EAAqC,IACrCC,EAA2B,CACtC,iBACA,OACA,iBCmCIC,EAAkBC,OAAQC,QAAAA,EAASC,UAAAA,EAAWC,IAAAA,YAgB5CC,EAAO,CACXC,KD3DsC,gBC4DtCC,KD3DsC,2BC4D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AKa,EAA2Ba,SACrDZ,EAASK,eAENN,EAA2Bc,qDCzMxC,MAkBEtC,YAAYuC,QACLvB,EAAmB,IAAIjB,EAAqBwC,GAgBnDC,gBAAerD,UAACA,EAADqB,YAAYA,EAAZC,YAAyBA,EAAzBI,QAAsCA,EAAtCH,MAA+CA,IAsBvDF,QAIAQ,EAAiBT,gBAAgB,CACpCpB,UAAAA,EACAqB,YAAAA,EACAC,YAAAA,EACAC,MAAAA,EACAtB,IAAKyB,EAAQzB"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.cacheableResponse = (function (exports, WorkboxError_mjs, assert_mjs, getFriendlyURL_mjs, logger_mjs) {
'use strict';
try {
self['workbox:cacheable-response:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This class allows you to set up rules determining what
* status codes and/or headers need to be present in order for a
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
* to be considered cacheable.
*
* @memberof workbox.cacheableResponse
*/
class CacheableResponse {
/**
* To construct a new CacheableResponse instance you must provide at least
* one of the `config` properties.
*
* If both `statuses` and `headers` are specified, then both conditions must
* be met for the `Response` to be considered cacheable.
*
* @param {Object} config
* @param {Array<number>} [config.statuses] One or more status codes that a
* `Response` can have and be considered cacheable.
* @param {Object<string,string>} [config.headers] A mapping of header names
* and expected values that a `Response` can have and be considered cacheable.
* If multiple headers are provided, only one needs to be present.
*/
constructor(config = {}) {
{
if (!(config.statuses || config.headers)) {
throw new WorkboxError_mjs.WorkboxError('statuses-or-headers-required', {
moduleName: 'workbox-cacheable-response',
className: 'CacheableResponse',
funcName: 'constructor'
});
}
if (config.statuses) {
assert_mjs.assert.isArray(config.statuses, {
moduleName: 'workbox-cacheable-response',
className: 'CacheableResponse',
funcName: 'constructor',
paramName: 'config.statuses'
});
}
if (config.headers) {
assert_mjs.assert.isType(config.headers, 'object', {
moduleName: 'workbox-cacheable-response',
className: 'CacheableResponse',
funcName: 'constructor',
paramName: 'config.headers'
});
}
}
this._statuses = config.statuses;
this._headers = config.headers;
}
/**
* Checks a response to see whether it's cacheable or not, based on this
* object's configuration.
*
* @param {Response} response The response whose cacheability is being
* checked.
* @return {boolean} `true` if the `Response` is cacheable, and `false`
* otherwise.
*/
isResponseCacheable(response) {
{
assert_mjs.assert.isInstance(response, Response, {
moduleName: 'workbox-cacheable-response',
className: 'CacheableResponse',
funcName: 'isResponseCacheable',
paramName: 'response'
});
}
let cacheable = true;
if (this._statuses) {
cacheable = this._statuses.includes(response.status);
}
if (this._headers && cacheable) {
cacheable = Object.keys(this._headers).some(headerName => {
return response.headers.get(headerName) === this._headers[headerName];
});
}
{
if (!cacheable) {
logger_mjs.logger.groupCollapsed(`The request for ` + `'${getFriendlyURL_mjs.getFriendlyURL(response.url)}' returned a response that does ` + `not meet the criteria for being cached.`);
logger_mjs.logger.groupCollapsed(`View cacheability criteria here.`);
logger_mjs.logger.log(`Cacheable statuses: ` + JSON.stringify(this._statuses));
logger_mjs.logger.log(`Cacheable headers: ` + JSON.stringify(this._headers, null, 2));
logger_mjs.logger.groupEnd();
const logFriendlyHeaders = {};
response.headers.forEach((value, key) => {
logFriendlyHeaders[key] = value;
});
logger_mjs.logger.groupCollapsed(`View response status and headers here.`);
logger_mjs.logger.log(`Response status: ` + response.status);
logger_mjs.logger.log(`Response headers: ` + JSON.stringify(logFriendlyHeaders, null, 2));
logger_mjs.logger.groupEnd();
logger_mjs.logger.groupCollapsed(`View full response details here.`);
logger_mjs.logger.log(response.headers);
logger_mjs.logger.log(response);
logger_mjs.logger.groupEnd();
logger_mjs.logger.groupEnd();
}
}
return cacheable;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A class implementing the `cacheWillUpdate` lifecycle callback. This makes it
* easier to add in cacheability checks to requests made via Workbox's built-in
* strategies.
*
* @memberof workbox.cacheableResponse
*/
class Plugin {
/**
* To construct a new cacheable response Plugin instance you must provide at
* least one of the `config` properties.
*
* If both `statuses` and `headers` are specified, then both conditions must
* be met for the `Response` to be considered cacheable.
*
* @param {Object} config
* @param {Array<number>} [config.statuses] One or more status codes that a
* `Response` can have and be considered cacheable.
* @param {Object<string,string>} [config.headers] A mapping of header names
* and expected values that a `Response` can have and be considered cacheable.
* If multiple headers are provided, only one needs to be present.
*/
constructor(config) {
this._cacheableResponse = new CacheableResponse(config);
}
/**
* @param {Object} options
* @param {Response} options.response
* @return {boolean}
* @private
*/
cacheWillUpdate({
response
}) {
if (this._cacheableResponse.isResponseCacheable(response)) {
return response;
}
return null;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.CacheableResponse = CacheableResponse;
exports.Plugin = Plugin;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-cacheable-response.dev.js.map
{"version":3,"file":"workbox-cacheable-response.dev.js","sources":["../_version.mjs","../CacheableResponse.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:cacheable-response:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport './_version.mjs';\n\n/**\n * This class allows you to set up rules determining what\n * status codes and/or headers need to be present in order for a\n * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * to be considered cacheable.\n *\n * @memberof workbox.cacheableResponse\n */\nclass CacheableResponse {\n /**\n * To construct a new CacheableResponse instance you must provide at least\n * one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.statuses || config.headers)) {\n throw new WorkboxError('statuses-or-headers-required', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n });\n }\n\n if (config.statuses) {\n assert.isArray(config.statuses, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.statuses',\n });\n }\n\n if (config.headers) {\n assert.isType(config.headers, 'object', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.headers',\n });\n }\n }\n\n this._statuses = config.statuses;\n this._headers = config.headers;\n }\n\n /**\n * Checks a response to see whether it's cacheable or not, based on this\n * object's configuration.\n *\n * @param {Response} response The response whose cacheability is being\n * checked.\n * @return {boolean} `true` if the `Response` is cacheable, and `false`\n * otherwise.\n */\n isResponseCacheable(response) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(response, Response, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'isResponseCacheable',\n paramName: 'response',\n });\n }\n\n let cacheable = true;\n\n if (this._statuses) {\n cacheable = this._statuses.includes(response.status);\n }\n\n if (this._headers && cacheable) {\n cacheable = Object.keys(this._headers).some((headerName) => {\n return response.headers.get(headerName) === this._headers[headerName];\n });\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (!cacheable) {\n logger.groupCollapsed(`The request for ` +\n `'${getFriendlyURL(response.url)}' returned a response that does ` +\n `not meet the criteria for being cached.`);\n\n logger.groupCollapsed(`View cacheability criteria here.`);\n logger.log(`Cacheable statuses: ` +\n JSON.stringify(this._statuses));\n logger.log(`Cacheable headers: ` +\n JSON.stringify(this._headers, null, 2));\n logger.groupEnd();\n\n const logFriendlyHeaders = {};\n response.headers.forEach((value, key) => {\n logFriendlyHeaders[key] = value;\n });\n\n logger.groupCollapsed(`View response status and headers here.`);\n logger.log(`Response status: ` + response.status);\n logger.log(`Response headers: ` +\n JSON.stringify(logFriendlyHeaders, null, 2));\n logger.groupEnd();\n\n logger.groupCollapsed(`View full response details here.`);\n logger.log(response.headers);\n logger.log(response);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n }\n\n return cacheable;\n }\n}\n\nexport {CacheableResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheableResponse} from './CacheableResponse.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it\n * easier to add in cacheability checks to requests made via Workbox's built-in\n * strategies.\n *\n * @memberof workbox.cacheableResponse\n */\nclass Plugin {\n /**\n * To construct a new cacheable response Plugin instance you must provide at\n * least one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config) {\n this._cacheableResponse = new CacheableResponse(config);\n }\n\n /**\n * @param {Object} options\n * @param {Response} options.response\n * @return {boolean}\n * @private\n */\n cacheWillUpdate({response}) {\n if (this._cacheableResponse.isResponseCacheable(response)) {\n return response;\n }\n return null;\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheableResponse} from './CacheableResponse.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.cacheableResponse\n */\n\nexport {\n CacheableResponse,\n Plugin,\n};\n"],"names":["self","_","e","CacheableResponse","constructor","config","statuses","headers","WorkboxError","moduleName","className","funcName","assert","isArray","paramName","isType","_statuses","_headers","isResponseCacheable","response","isInstance","Response","cacheable","includes","status","Object","keys","some","headerName","get","logger","groupCollapsed","getFriendlyURL","url","log","JSON","stringify","groupEnd","logFriendlyHeaders","forEach","value","key","Plugin","_cacheableResponse","cacheWillUpdate"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,kCAAD,CAAJ,IAA0CC,CAAC,EAA3C;EAA8C,CAAlD,CAAkD,OAAMC,CAAN,EAAQ;;ECA1D;;;;;;;AAQA,EAMA;;;;;;;;;EAQA,MAAMC,iBAAN,CAAwB;EACtB;;;;;;;;;;;;;;EAcAC,EAAAA,WAAW,CAACC,MAAM,GAAG,EAAV,EAAc;EACvB,IAA2C;EACzC,UAAI,EAAEA,MAAM,CAACC,QAAP,IAAmBD,MAAM,CAACE,OAA5B,CAAJ,EAA0C;EACxC,cAAM,IAAIC,6BAAJ,CAAiB,8BAAjB,EAAiD;EACrDC,UAAAA,UAAU,EAAE,4BADyC;EAErDC,UAAAA,SAAS,EAAE,mBAF0C;EAGrDC,UAAAA,QAAQ,EAAE;EAH2C,SAAjD,CAAN;EAKD;;EAED,UAAIN,MAAM,CAACC,QAAX,EAAqB;EACnBM,QAAAA,iBAAM,CAACC,OAAP,CAAeR,MAAM,CAACC,QAAtB,EAAgC;EAC9BG,UAAAA,UAAU,EAAE,4BADkB;EAE9BC,UAAAA,SAAS,EAAE,mBAFmB;EAG9BC,UAAAA,QAAQ,EAAE,aAHoB;EAI9BG,UAAAA,SAAS,EAAE;EAJmB,SAAhC;EAMD;;EAED,UAAIT,MAAM,CAACE,OAAX,EAAoB;EAClBK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tB,CAA1B;EACD;EAED;;;;;;;;EAMAuC,EAAAA,eAAe,CAAC;EAACzB,IAAAA;EAAD,GAAD,EAAa;EAC1B,QAAI,KAAKwB,kBAAL,CAAwBzB,mBAAxB,CAA4CC,QAA5C,CAAJ,EAA2D;EACzD,aAAOA,QAAP;EACD;;EACD,WAAO,IAAP;EACD;;EA9BU;;EClBb;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(t){"use strict";try{self["workbox:cacheable-response:4.3.1"]&&_()}catch(t){}class s{constructor(t={}){this.t=t.statuses,this.s=t.headers}isResponseCacheable(t){let s=!0;return this.t&&(s=this.t.includes(t.status)),this.s&&s&&(s=Object.keys(this.s).some(s=>t.headers.get(s)===this.s[s])),s}}return t.CacheableResponse=s,t.Plugin=class{constructor(t){this.i=new s(t)}cacheWillUpdate({response:t}){return this.i.isResponseCacheable(t)?t:null}},t}({});
//# sourceMappingURL=workbox-cacheable-response.prod.js.map
{"version":3,"file":"workbox-cacheable-response.prod.js","sources":["../_version.mjs","../CacheableResponse.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:cacheable-response:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport './_version.mjs';\n\n/**\n * This class allows you to set up rules determining what\n * status codes and/or headers need to be present in order for a\n * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * to be considered cacheable.\n *\n * @memberof workbox.cacheableResponse\n */\nclass CacheableResponse {\n /**\n * To construct a new CacheableResponse instance you must provide at least\n * one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.statuses || config.headers)) {\n throw new WorkboxError('statuses-or-headers-required', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n });\n }\n\n if (config.statuses) {\n assert.isArray(config.statuses, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.statuses',\n });\n }\n\n if (config.headers) {\n assert.isType(config.headers, 'object', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.headers',\n });\n }\n }\n\n this._statuses = config.statuses;\n this._headers = config.headers;\n }\n\n /**\n * Checks a response to see whether it's cacheable or not, based on this\n * object's configuration.\n *\n * @param {Response} response The response whose cacheability is being\n * checked.\n * @return {boolean} `true` if the `Response` is cacheable, and `false`\n * otherwise.\n */\n isResponseCacheable(response) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(response, Response, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'isResponseCacheable',\n paramName: 'response',\n });\n }\n\n let cacheable = true;\n\n if (this._statuses) {\n cacheable = this._statuses.includes(response.status);\n }\n\n if (this._headers && cacheable) {\n cacheable = Object.keys(this._headers).some((headerName) => {\n return response.headers.get(headerName) === this._headers[headerName];\n });\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (!cacheable) {\n logger.groupCollapsed(`The request for ` +\n `'${getFriendlyURL(response.url)}' returned a response that does ` +\n `not meet the criteria for being cached.`);\n\n logger.groupCollapsed(`View cacheability criteria here.`);\n logger.log(`Cacheable statuses: ` +\n JSON.stringify(this._statuses));\n logger.log(`Cacheable headers: ` +\n JSON.stringify(this._headers, null, 2));\n logger.groupEnd();\n\n const logFriendlyHeaders = {};\n response.headers.forEach((value, key) => {\n logFriendlyHeaders[key] = value;\n });\n\n logger.groupCollapsed(`View response status and headers here.`);\n logger.log(`Response status: ` + response.status);\n logger.log(`Response headers: ` +\n JSON.stringify(logFriendlyHeaders, null, 2));\n logger.groupEnd();\n\n logger.groupCollapsed(`View full response details here.`);\n logger.log(response.headers);\n logger.log(response);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n }\n\n return cacheable;\n }\n}\n\nexport {CacheableResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheableResponse} from './CacheableResponse.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it\n * easier to add in cacheability checks to requests made via Workbox's built-in\n * strategies.\n *\n * @memberof workbox.cacheableResponse\n */\nclass Plugin {\n /**\n * To construct a new cacheable response Plugin instance you must provide at\n * least one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config) {\n this._cacheableResponse = new CacheableResponse(config);\n }\n\n /**\n * @param {Object} options\n * @param {Response} options.response\n * @return {boolean}\n * @private\n */\n cacheWillUpdate({response}) {\n if (this._cacheableResponse.isResponseCacheable(response)) {\n return response;\n }\n return null;\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","CacheableResponse","constructor","config","_statuses","statuses","_headers","headers","isResponseCacheable","response","cacheable","this","includes","status","Object","keys","some","headerName","get","_cacheableResponse","cacheWillUpdate"],"mappings":"sFAAA,IAAIA,KAAK,qCAAqCC,IAAI,MAAMC,ICsBxD,MAAMC,EAeJC,YAAYC,EAAS,SA6BdC,EAAYD,EAAOE,cACnBC,EAAWH,EAAOI,QAYzBC,oBAAoBC,OAUdC,GAAY,SAEZC,KAAKP,IACPM,EAAYC,KAAKP,EAAUQ,SAASH,EAASI,SAG3CF,KAAKL,GAAYI,IACnBA,EAAYI,OAAOC,KAAKJ,KAAKL,GAAUU,KAAMC,GACpCR,EAASF,QAAQW,IAAID,KAAgBN,KAAKL,EAASW,KAqCvDP,yCCpHX,MAeER,YAAYC,QACLgB,EAAqB,IAAIlB,EAAkBE,GASlDiB,iBAAgBX,SAACA,WACXE,KAAKQ,EAAmBX,oBAAoBC,GACvCA,EAEF"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.core = (function (exports) {
'use strict';
try {
self['workbox:core:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const logger = (() => {
let inGroup = false;
const methodToColorMap = {
debug: `#7f8c8d`,
// Gray
log: `#2ecc71`,
// Green
warn: `#f39c12`,
// Yellow
error: `#c0392b`,
// Red
groupCollapsed: `#3498db`,
// Blue
groupEnd: null // No colored prefix on groupEnd
};
const print = function (method, args) {
if (method === 'groupCollapsed') {
// Safari doesn't print all console.groupCollapsed() arguments:
// https://bugs.webkit.org/show_bug.cgi?id=182754
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
console[method](...args);
return;
}
}
const styles = [`background: ${methodToColorMap[method]}`, `border-radius: 0.5em`, `color: white`, `font-weight: bold`, `padding: 2px 0.5em`]; // When in a group, the workbox prefix is not displayed.
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
console[method](...logPrefix, ...args);
if (method === 'groupCollapsed') {
inGroup = true;
}
if (method === 'groupEnd') {
inGroup = false;
}
};
const api = {};
for (const method of Object.keys(methodToColorMap)) {
api[method] = (...args) => {
print(method, args);
};
}
return api;
})();
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const messages = {
'invalid-value': ({
paramName,
validValueDescription,
value
}) => {
if (!paramName || !validValueDescription) {
throw new Error(`Unexpected input to 'invalid-value' error.`);
}
return `The '${paramName}' parameter was given a value with an ` + `unexpected value. ${validValueDescription} Received a value of ` + `${JSON.stringify(value)}.`;
},
'not-in-sw': ({
moduleName
}) => {
if (!moduleName) {
throw new Error(`Unexpected input to 'not-in-sw' error.`);
}
return `The '${moduleName}' must be used in a service worker.`;
},
'not-an-array': ({
moduleName,
className,
funcName,
paramName
}) => {
if (!moduleName || !className || !funcName || !paramName) {
throw new Error(`Unexpected input to 'not-an-array' error.`);
}
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className}.${funcName}()' must be an array.`;
},
'incorrect-type': ({
expectedType,
paramName,
moduleName,
className,
funcName
}) => {
if (!expectedType || !paramName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'incorrect-type' error.`);
}
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}` + `${funcName}()' must be of type ${expectedType}.`;
},
'incorrect-class': ({
expectedClass,
paramName,
moduleName,
className,
funcName,
isReturnValueProblem
}) => {
if (!expectedClass || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'incorrect-class' error.`);
}
if (isReturnValueProblem) {
return `The return value from ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
}
return `The parameter '${paramName}' passed into ` + `'${moduleName}.${className ? className + '.' : ''}${funcName}()' ` + `must be an instance of class ${expectedClass.name}.`;
},
'missing-a-method': ({
expectedMethod,
paramName,
moduleName,
className,
funcName
}) => {
if (!expectedMethod || !paramName || !moduleName || !className || !funcName) {
throw new Error(`Unexpected input to 'missing-a-method' error.`);
}
return `${moduleName}.${className}.${funcName}() expected the ` + `'${paramName}' parameter to expose a '${expectedMethod}' method.`;
},
'add-to-cache-list-unexpected-type': ({
entry
}) => {
return `An unexpected entry was passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + `strings with one or more characters, objects with a url property or ` + `Request objects.`;
},
'add-to-cache-list-conflicting-entries': ({
firstEntry,
secondEntry
}) => {
if (!firstEntry || !secondEntry) {
throw new Error(`Unexpected input to ` + `'add-to-cache-list-duplicate-entries' error.`);
}
return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${firstEntry._entryId} but different revision details. Workbox is ` + `is unable to cache and version the asset correctly. Please remove one ` + `of the entries.`;
},
'plugin-error-request-will-fetch': ({
thrownError
}) => {
if (!thrownError) {
throw new Error(`Unexpected input to ` + `'plugin-error-request-will-fetch', error.`);
}
return `An error was thrown by a plugins 'requestWillFetch()' method. ` + `The thrown error message was: '${thrownError.message}'.`;
},
'invalid-cache-name': ({
cacheNameId,
value
}) => {
if (!cacheNameId) {
throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
}
return `You must provide a name containing at least one character for ` + `setCacheDeatils({${cacheNameId}: '...'}). Received a value of ` + `'${JSON.stringify(value)}'`;
},
'unregister-route-but-not-found-with-method': ({
method
}) => {
if (!method) {
throw new Error(`Unexpected input to ` + `'unregister-route-but-not-found-with-method' error.`);
}
return `The route you're trying to unregister was not previously ` + `registered for the method type '${method}'.`;
},
'unregister-route-route-not-registered': () => {
return `The route you're trying to unregister was not previously ` + `registered.`;
},
'queue-replay-failed': ({
name
}) => {
return `Replaying the background sync queue '${name}' failed.`;
},
'duplicate-queue-name': ({
name
}) => {
return `The Queue name '${name}' is already being used. ` + `All instances of backgroundSync.Queue must be given unique names.`;
},
'expired-test-without-max-age': ({
methodName,
paramName
}) => {
return `The '${methodName}()' method can only be used when the ` + `'${paramName}' is used in the constructor.`;
},
'unsupported-route-type': ({
moduleName,
className,
funcName,
paramName
}) => {
return `The supplied '${paramName}' parameter was an unsupported type. ` + `Please check the docs for ${moduleName}.${className}.${funcName} for ` + `valid input types.`;
},
'not-array-of-class': ({
value,
expectedClass,
moduleName,
className,
funcName,
paramName
}) => {
return `The supplied '${paramName}' parameter must be an array of ` + `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + `Please check the call to ${moduleName}.${className}.${funcName}() ` + `to fix the issue.`;
},
'max-entries-or-age-required': ({
moduleName,
className,
funcName
}) => {
return `You must define either config.maxEntries or config.maxAgeSeconds` + `in ${moduleName}.${className}.${funcName}`;
},
'statuses-or-headers-required': ({
moduleName,
className,
funcName
}) => {
return `You must define either config.statuses or config.headers` + `in ${moduleName}.${className}.${funcName}`;
},
'invalid-string': ({
moduleName,
className,
funcName,
paramName
}) => {
if (!paramName || !moduleName || !funcName) {
throw new Error(`Unexpected input to 'invalid-string' error.`);
}
return `When using strings, the '${paramName}' parameter must start with ` + `'http' (for cross-origin matches) or '/' (for same-origin matches). ` + `Please see the docs for ${moduleName}.${funcName}() for ` + `more info.`;
},
'channel-name-required': () => {
return `You must provide a channelName to construct a ` + `BroadcastCacheUpdate instance.`;
},
'invalid-responses-are-same-args': () => {
return `The arguments passed into responsesAreSame() appear to be ` + `invalid. Please ensure valid Responses are used.`;
},
'expire-custom-caches-only': () => {
return `You must provide a 'cacheName' property when using the ` + `expiration plugin with a runtime caching strategy.`;
},
'unit-must-be-bytes': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);
}
return `The 'unit' portion of the Range header must be set to 'bytes'. ` + `The Range header provided was "${normalizedRangeHeader}"`;
},
'single-range-only': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'single-range-only' error.`);
}
return `Multiple ranges are not supported. Please use a single start ` + `value, and optional end value. The Range header provided was ` + `"${normalizedRangeHeader}"`;
},
'invalid-range-values': ({
normalizedRangeHeader
}) => {
if (!normalizedRangeHeader) {
throw new Error(`Unexpected input to 'invalid-range-values' error.`);
}
return `The Range header is missing both start and end values. At least ` + `one of those values is needed. The Range header provided was ` + `"${normalizedRangeHeader}"`;
},
'no-range-header': () => {
return `No Range header was found in the Request provided.`;
},
'range-not-satisfiable': ({
size,
start,
end
}) => {
return `The start (${start}) and end (${end}) values in the Range are ` + `not satisfiable by the cached response, which is ${size} bytes.`;
},
'attempt-to-cache-non-get-request': ({
url,
method
}) => {
return `Unable to cache '${url}' because it is a '${method}' request and ` + `only 'GET' requests can be cached.`;
},
'cache-put-with-no-response': ({
url
}) => {
return `There was an attempt to cache '${url}' but the response was not ` + `defined.`;
},
'no-response': ({
url,
error
}) => {
let message = `The strategy could not generate a response for '${url}'.`;
if (error) {
message += ` The underlying error is ${error}.`;
}
return message;
},
'bad-precaching-response': ({
url,
status
}) => {
return `The precaching request for '${url}' failed with an HTTP ` + `status of ${status}.`;
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const generatorFunction = (code, ...args) => {
const message = messages[code];
if (!message) {
throw new Error(`Unable to find message for code '${code}'.`);
}
return message(...args);
};
const messageGenerator = generatorFunction;
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Workbox errors should be thrown with this class.
* This allows use to ensure the type easily in tests,
* helps developers identify errors from workbox
* easily and allows use to optimise error
* messages correctly.
*
* @private
*/
class WorkboxError extends Error {
/**
*
* @param {string} errorCode The error code that
* identifies this particular error.
* @param {Object=} details Any relevant arguments
* that will help developers identify issues should
* be added as a key on the context object.
*/
constructor(errorCode, details) {
let message = messageGenerator(errorCode, details);
super(message);
this.name = errorCode;
this.details = details;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/*
* This method returns true if the current context is a service worker.
*/
const isSWEnv = moduleName => {
if (!('ServiceWorkerGlobalScope' in self)) {
throw new WorkboxError('not-in-sw', {
moduleName
});
}
};
/*
* This method throws if the supplied value is not an array.
* The destructed values are required to produce a meaningful error for users.
* The destructed and restructured object is so it's clear what is
* needed.
*/
const isArray = (value, {
moduleName,
className,
funcName,
paramName
}) => {
if (!Array.isArray(value)) {
throw new WorkboxError('not-an-array', {
moduleName,
className,
funcName,
paramName
});
}
};
const hasMethod = (object, expectedMethod, {
moduleName,
className,
funcName,
paramName
}) => {
const type = typeof object[expectedMethod];
if (type !== 'function') {
throw new WorkboxError('missing-a-method', {
paramName,
expectedMethod,
moduleName,
className,
funcName
});
}
};
const isType = (object, expectedType, {
moduleName,
className,
funcName,
paramName
}) => {
if (typeof object !== expectedType) {
throw new WorkboxError('incorrect-type', {
paramName,
expectedType,
moduleName,
className,
funcName
});
}
};
const isInstance = (object, expectedClass, {
moduleName,
className,
funcName,
paramName,
isReturnValueProblem
}) => {
if (!(object instanceof expectedClass)) {
throw new WorkboxError('incorrect-class', {
paramName,
expectedClass,
moduleName,
className,
funcName,
isReturnValueProblem
});
}
};
const isOneOf = (value, validValues, {
paramName
}) => {
if (!validValues.includes(value)) {
throw new WorkboxError('invalid-value', {
paramName,
value,
validValueDescription: `Valid values are ${JSON.stringify(validValues)}.`
});
}
};
const isArrayOfClass = (value, expectedClass, {
moduleName,
className,
funcName,
paramName
}) => {
const error = new WorkboxError('not-array-of-class', {
value,
expectedClass,
moduleName,
className,
funcName,
paramName
});
if (!Array.isArray(value)) {
throw error;
}
for (let item of value) {
if (!(item instanceof expectedClass)) {
throw error;
}
}
};
const finalAssertExports = {
hasMethod,
isArray,
isInstance,
isOneOf,
isSWEnv,
isType,
isArrayOfClass
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const quotaErrorCallbacks = new Set();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Adds a function to the set of quotaErrorCallbacks that will be executed if
* there's a quota error.
*
* @param {Function} callback
* @memberof workbox.core
*/
function registerQuotaErrorCallback(callback) {
{
finalAssertExports.isType(callback, 'function', {
moduleName: 'workbox-core',
funcName: 'register',
paramName: 'callback'
});
}
quotaErrorCallbacks.add(callback);
{
logger.log('Registered a callback to respond to quota errors.', callback);
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const _cacheNameDetails = {
googleAnalytics: 'googleAnalytics',
precache: 'precache-v2',
prefix: 'workbox',
runtime: 'runtime',
suffix: self.registration.scope
};
const _createCacheName = cacheName => {
return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix].filter(value => value.length > 0).join('-');
};
const cacheNames = {
updateDetails: details => {
Object.keys(_cacheNameDetails).forEach(key => {
if (typeof details[key] !== 'undefined') {
_cacheNameDetails[key] = details[key];
}
});
},
getGoogleAnalyticsName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);
},
getPrecacheName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.precache);
},
getPrefix: () => {
return _cacheNameDetails.prefix;
},
getRuntimeName: userCacheName => {
return userCacheName || _createCacheName(_cacheNameDetails.runtime);
},
getSuffix: () => {
return _cacheNameDetails.suffix;
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const getFriendlyURL = url => {
const urlObj = new URL(url, location);
if (urlObj.origin === location.origin) {
return urlObj.pathname;
}
return urlObj.href;
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Runs all of the callback functions, one at a time sequentially, in the order
* in which they were registered.
*
* @memberof workbox.core
* @private
*/
async function executeQuotaErrorCallbacks() {
{
logger.log(`About to run ${quotaErrorCallbacks.size} ` + `callbacks to clean up caches.`);
}
for (const callback of quotaErrorCallbacks) {
await callback();
{
logger.log(callback, 'is complete.');
}
}
{
logger.log('Finished running callbacks.');
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const pluginEvents = {
CACHE_DID_UPDATE: 'cacheDidUpdate',
CACHE_KEY_WILL_BE_USED: 'cacheKeyWillBeUsed',
CACHE_WILL_UPDATE: 'cacheWillUpdate',
CACHED_RESPONSE_WILL_BE_USED: 'cachedResponseWillBeUsed',
FETCH_DID_FAIL: 'fetchDidFail',
FETCH_DID_SUCCEED: 'fetchDidSucceed',
REQUEST_WILL_FETCH: 'requestWillFetch'
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const pluginUtils = {
filter: (plugins, callbackName) => {
return plugins.filter(plugin => callbackName in plugin);
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Wrapper around cache.put().
*
* Will call `cacheDidUpdate` on plugins if the cache was updated, using
* `matchOptions` when determining what the old entry is.
*
* @param {Object} options
* @param {string} options.cacheName
* @param {Request} options.request
* @param {Response} options.response
* @param {Event} [options.event]
* @param {Array<Object>} [options.plugins=[]]
* @param {Object} [options.matchOptions]
*
* @private
* @memberof module:workbox-core
*/
const putWrapper = async ({
cacheName,
request,
response,
event,
plugins = [],
matchOptions
} = {}) => {
{
if (request.method && request.method !== 'GET') {
throw new WorkboxError('attempt-to-cache-non-get-request', {
url: getFriendlyURL(request.url),
method: request.method
});
}
}
const effectiveRequest = await _getEffectiveRequest({
plugins,
request,
mode: 'write'
});
if (!response) {
{
logger.error(`Cannot cache non-existent response for ` + `'${getFriendlyURL(effectiveRequest.url)}'.`);
}
throw new WorkboxError('cache-put-with-no-response', {
url: getFriendlyURL(effectiveRequest.url)
});
}
let responseToCache = await _isResponseSafeToCache({
event,
plugins,
response,
request: effectiveRequest
});
if (!responseToCache) {
{
logger.debug(`Response '${getFriendlyURL(effectiveRequest.url)}' will ` + `not be cached.`, responseToCache);
}
return;
}
const cache = await caches.open(cacheName);
const updatePlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_DID_UPDATE);
let oldResponse = updatePlugins.length > 0 ? await matchWrapper({
cacheName,
matchOptions,
request: effectiveRequest
}) : null;
{
logger.debug(`Updating the '${cacheName}' cache with a new Response for ` + `${getFriendlyURL(effectiveRequest.url)}.`);
}
try {
await cache.put(effectiveRequest, responseToCache);
} catch (error) {
// See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError
if (error.name === 'QuotaExceededError') {
await executeQuotaErrorCallbacks();
}
throw error;
}
for (let plugin of updatePlugins) {
await plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {
cacheName,
event,
oldResponse,
newResponse: responseToCache,
request: effectiveRequest
});
}
};
/**
* This is a wrapper around cache.match().
*
* @param {Object} options
* @param {string} options.cacheName Name of the cache to match against.
* @param {Request} options.request The Request that will be used to look up
* cache entries.
* @param {Event} [options.event] The event that propted the action.
* @param {Object} [options.matchOptions] Options passed to cache.match().
* @param {Array<Object>} [options.plugins=[]] Array of plugins.
* @return {Response} A cached response if available.
*
* @private
* @memberof module:workbox-core
*/
const matchWrapper = async ({
cacheName,
request,
event,
matchOptions,
plugins = []
}) => {
const cache = await caches.open(cacheName);
const effectiveRequest = await _getEffectiveRequest({
plugins,
request,
mode: 'read'
});
let cachedResponse = await cache.match(effectiveRequest, matchOptions);
{
if (cachedResponse) {
logger.debug(`Found a cached response in '${cacheName}'.`);
} else {
logger.debug(`No cached response found in '${cacheName}'.`);
}
}
for (const plugin of plugins) {
if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {
cachedResponse = await plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED].call(plugin, {
cacheName,
event,
matchOptions,
cachedResponse,
request: effectiveRequest
});
{
if (cachedResponse) {
finalAssertExports.isInstance(cachedResponse, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
}
}
return cachedResponse;
};
/**
* This method will call cacheWillUpdate on the available plugins (or use
* status === 200) to determine if the Response is safe and valid to cache.
*
* @param {Object} options
* @param {Request} options.request
* @param {Response} options.response
* @param {Event} [options.event]
* @param {Array<Object>} [options.plugins=[]]
* @return {Promise<Response>}
*
* @private
* @memberof module:workbox-core
*/
const _isResponseSafeToCache = async ({
request,
response,
event,
plugins
}) => {
let responseToCache = response;
let pluginsUsed = false;
for (let plugin of plugins) {
if (pluginEvents.CACHE_WILL_UPDATE in plugin) {
pluginsUsed = true;
responseToCache = await plugin[pluginEvents.CACHE_WILL_UPDATE].call(plugin, {
request,
response: responseToCache,
event
});
{
if (responseToCache) {
finalAssertExports.isInstance(responseToCache, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHE_WILL_UPDATE,
isReturnValueProblem: true
});
}
}
if (!responseToCache) {
break;
}
}
}
if (!pluginsUsed) {
{
if (!responseToCache.status === 200) {
if (responseToCache.status === 0) {
logger.warn(`The response for '${request.url}' is an opaque ` + `response. The caching strategy that you're using will not ` + `cache opaque responses by default.`);
} else {
logger.debug(`The response for '${request.url}' returned ` + `a status code of '${response.status}' and won't be cached as a ` + `result.`);
}
}
}
responseToCache = responseToCache.status === 200 ? responseToCache : null;
}
return responseToCache ? responseToCache : null;
};
/**
* Checks the list of plugins for the cacheKeyWillBeUsed callback, and
* executes any of those callbacks found in sequence. The final `Request` object
* returned by the last plugin is treated as the cache key for cache reads
* and/or writes.
*
* @param {Object} options
* @param {Request} options.request
* @param {string} options.mode
* @param {Array<Object>} [options.plugins=[]]
* @return {Promise<Request>}
*
* @private
* @memberof module:workbox-core
*/
const _getEffectiveRequest = async ({
request,
mode,
plugins
}) => {
const cacheKeyWillBeUsedPlugins = pluginUtils.filter(plugins, pluginEvents.CACHE_KEY_WILL_BE_USED);
let effectiveRequest = request;
for (const plugin of cacheKeyWillBeUsedPlugins) {
effectiveRequest = await plugin[pluginEvents.CACHE_KEY_WILL_BE_USED].call(plugin, {
mode,
request: effectiveRequest
});
if (typeof effectiveRequest === 'string') {
effectiveRequest = new Request(effectiveRequest);
}
{
finalAssertExports.isInstance(effectiveRequest, Request, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHE_KEY_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
return effectiveRequest;
};
const cacheWrapper = {
put: putWrapper,
match: matchWrapper
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A class that wraps common IndexedDB functionality in a promise-based API.
* It exposes all the underlying power and functionality of IndexedDB, but
* wraps the most commonly used features in a way that's much simpler to use.
*
* @private
*/
class DBWrapper {
/**
* @param {string} name
* @param {number} version
* @param {Object=} [callback]
* @param {!Function} [callbacks.onupgradeneeded]
* @param {!Function} [callbacks.onversionchange] Defaults to
* DBWrapper.prototype._onversionchange when not specified.
* @private
*/
constructor(name, version, {
onupgradeneeded,
onversionchange = this._onversionchange
} = {}) {
this._name = name;
this._version = version;
this._onupgradeneeded = onupgradeneeded;
this._onversionchange = onversionchange; // If this is null, it means the database isn't open.
this._db = null;
}
/**
* Returns the IDBDatabase instance (not normally needed).
*
* @private
*/
get db() {
return this._db;
}
/**
* Opens a connected to an IDBDatabase, invokes any onupgradedneeded
* callback, and added an onversionchange callback to the database.
*
* @return {IDBDatabase}
* @private
*/
async open() {
if (this._db) return;
this._db = await new Promise((resolve, reject) => {
// This flag is flipped to true if the timeout callback runs prior
// to the request failing or succeeding. Note: we use a timeout instead
// of an onblocked handler since there are cases where onblocked will
// never never run. A timeout better handles all possible scenarios:
// https://github.com/w3c/IndexedDB/issues/223
let openRequestTimedOut = false;
setTimeout(() => {
openRequestTimedOut = true;
reject(new Error('The open request was blocked and timed out'));
}, this.OPEN_TIMEOUT);
const openRequest = indexedDB.open(this._name, this._version);
openRequest.onerror = () => reject(openRequest.error);
openRequest.onupgradeneeded = evt => {
if (openRequestTimedOut) {
openRequest.transaction.abort();
evt.target.result.close();
} else if (this._onupgradeneeded) {
this._onupgradeneeded(evt);
}
};
openRequest.onsuccess = ({
target
}) => {
const db = target.result;
if (openRequestTimedOut) {
db.close();
} else {
db.onversionchange = this._onversionchange.bind(this);
resolve(db);
}
};
});
return this;
}
/**
* Polyfills the native `getKey()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @return {Array}
* @private
*/
async getKey(storeName, query) {
return (await this.getAllKeys(storeName, query, 1))[0];
}
/**
* Polyfills the native `getAll()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @param {number} count
* @return {Array}
* @private
*/
async getAll(storeName, query, count) {
return await this.getAllMatching(storeName, {
query,
count
});
}
/**
* Polyfills the native `getAllKeys()` method. Note, this is overridden at
* runtime if the browser supports the native method.
*
* @param {string} storeName
* @param {*} query
* @param {number} count
* @return {Array}
* @private
*/
async getAllKeys(storeName, query, count) {
return (await this.getAllMatching(storeName, {
query,
count,
includeKeys: true
})).map(({
key
}) => key);
}
/**
* Supports flexible lookup in an object store by specifying an index,
* query, direction, and count. This method returns an array of objects
* with the signature .
*
* @param {string} storeName
* @param {Object} [opts]
* @param {string} [opts.index] The index to use (if specified).
* @param {*} [opts.query]
* @param {IDBCursorDirection} [opts.direction]
* @param {number} [opts.count] The max number of results to return.
* @param {boolean} [opts.includeKeys] When true, the structure of the
* returned objects is changed from an array of values to an array of
* objects in the form {key, primaryKey, value}.
* @return {Array}
* @private
*/
async getAllMatching(storeName, {
index,
query = null,
// IE errors if query === `undefined`.
direction = 'next',
count,
includeKeys
} = {}) {
return await this.transaction([storeName], 'readonly', (txn, done) => {
const store = txn.objectStore(storeName);
const target = index ? store.index(index) : store;
const results = [];
target.openCursor(query, direction).onsuccess = ({
target
}) => {
const cursor = target.result;
if (cursor) {
const {
primaryKey,
key,
value
} = cursor;
results.push(includeKeys ? {
primaryKey,
key,
value
} : value);
if (count && results.length >= count) {
done(results);
} else {
cursor.continue();
}
} else {
done(results);
}
};
});
}
/**
* Accepts a list of stores, a transaction type, and a callback and
* performs a transaction. A promise is returned that resolves to whatever
* value the callback chooses. The callback holds all the transaction logic
* and is invoked with two arguments:
* 1. The IDBTransaction object
* 2. A `done` function, that's used to resolve the promise when
* when the transaction is done, if passed a value, the promise is
* resolved to that value.
*
* @param {Array<string>} storeNames An array of object store names
* involved in the transaction.
* @param {string} type Can be `readonly` or `readwrite`.
* @param {!Function} callback
* @return {*} The result of the transaction ran by the callback.
* @private
*/
async transaction(storeNames, type, callback) {
await this.open();
return await new Promise((resolve, reject) => {
const txn = this._db.transaction(storeNames, type);
txn.onabort = ({
target
}) => reject(target.error);
txn.oncomplete = () => resolve();
callback(txn, value => resolve(value));
});
}
/**
* Delegates async to a native IDBObjectStore method.
*
* @param {string} method The method name.
* @param {string} storeName The object store name.
* @param {string} type Can be `readonly` or `readwrite`.
* @param {...*} args The list of args to pass to the native method.
* @return {*} The result of the transaction.
* @private
*/
async _call(method, storeName, type, ...args) {
const callback = (txn, done) => {
txn.objectStore(storeName)[method](...args).onsuccess = ({
target
}) => {
done(target.result);
};
};
return await this.transaction([storeName], type, callback);
}
/**
* The default onversionchange handler, which closes the database so other
* connections can open without being blocked.
*
* @private
*/
_onversionchange() {
this.close();
}
/**
* Closes the connection opened by `DBWrapper.open()`. Generally this method
* doesn't need to be called since:
* 1. It's usually better to keep a connection open since opening
* a new connection is somewhat slow.
* 2. Connections are automatically closed when the reference is
* garbage collected.
* The primary use case for needing to close a connection is when another
* reference (typically in another tab) needs to upgrade it and would be
* blocked by the current, open connection.
*
* @private
*/
close() {
if (this._db) {
this._db.close();
this._db = null;
}
}
} // Exposed to let users modify the default timeout on a per-instance
// or global basis.
DBWrapper.prototype.OPEN_TIMEOUT = 2000; // Wrap native IDBObjectStore methods according to their mode.
const methodsToWrap = {
'readonly': ['get', 'count', 'getKey', 'getAll', 'getAllKeys'],
'readwrite': ['add', 'put', 'clear', 'delete']
};
for (const [mode, methods] of Object.entries(methodsToWrap)) {
for (const method of methods) {
if (method in IDBObjectStore.prototype) {
// Don't use arrow functions here since we're outside of the class.
DBWrapper.prototype[method] = async function (storeName, ...args) {
return await this._call(method, storeName, mode, ...args);
};
}
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The Deferred class composes Promises in a way that allows for them to be
* resolved or rejected from outside the constructor. In most cases promises
* should be used directly, but Deferreds can be necessary when the logic to
* resolve a promise must be separate.
*
* @private
*/
class Deferred {
/**
* Creates a promise and exposes its resolve and reject functions as methods.
*/
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Deletes the database.
* Note: this is exported separately from the DBWrapper module because most
* usages of IndexedDB in workbox dont need deleting, and this way it can be
* reused in tests to delete databases without creating DBWrapper instances.
*
* @param {string} name The database name.
* @private
*/
const deleteDatabase = async name => {
await new Promise((resolve, reject) => {
const request = indexedDB.deleteDatabase(name);
request.onerror = ({
target
}) => {
reject(target.error);
};
request.onblocked = () => {
reject(new Error('Delete blocked'));
};
request.onsuccess = () => {
resolve();
};
});
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Wrapper around the fetch API.
*
* Will call requestWillFetch on available plugins.
*
* @param {Object} options
* @param {Request|string} options.request
* @param {Object} [options.fetchOptions]
* @param {Event} [options.event]
* @param {Array<Object>} [options.plugins=[]]
* @return {Promise<Response>}
*
* @private
* @memberof module:workbox-core
*/
const wrappedFetch = async ({
request,
fetchOptions,
event,
plugins = []
}) => {
// We *should* be able to call `await event.preloadResponse` even if it's
// undefined, but for some reason, doing so leads to errors in our Node unit
// tests. To work around that, explicitly check preloadResponse's value first.
if (event && event.preloadResponse) {
const possiblePreloadResponse = await event.preloadResponse;
if (possiblePreloadResponse) {
{
logger.log(`Using a preloaded navigation response for ` + `'${getFriendlyURL(request.url)}'`);
}
return possiblePreloadResponse;
}
}
if (typeof request === 'string') {
request = new Request(request);
}
{
finalAssertExports.isInstance(request, Request, {
paramName: request,
expectedClass: 'Request',
moduleName: 'workbox-core',
className: 'fetchWrapper',
funcName: 'wrappedFetch'
});
}
const failedFetchPlugins = pluginUtils.filter(plugins, pluginEvents.FETCH_DID_FAIL); // If there is a fetchDidFail plugin, we need to save a clone of the
// original request before it's either modified by a requestWillFetch
// plugin or before the original request's body is consumed via fetch().
const originalRequest = failedFetchPlugins.length > 0 ? request.clone() : null;
try {
for (let plugin of plugins) {
if (pluginEvents.REQUEST_WILL_FETCH in plugin) {
request = await plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {
request: request.clone(),
event
});
{
if (request) {
finalAssertExports.isInstance(request, Request, {
moduleName: 'Plugin',
funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,
isReturnValueProblem: true
});
}
}
}
}
} catch (err) {
throw new WorkboxError('plugin-error-request-will-fetch', {
thrownError: err
});
} // The request can be altered by plugins with `requestWillFetch` making
// the original request (Most likely from a `fetch` event) to be different
// to the Request we make. Pass both to `fetchDidFail` to aid debugging.
let pluginFilteredRequest = request.clone();
try {
let fetchResponse; // See https://github.com/GoogleChrome/workbox/issues/1796
if (request.mode === 'navigate') {
fetchResponse = await fetch(request);
} else {
fetchResponse = await fetch(request, fetchOptions);
}
{
logger.debug(`Network request for ` + `'${getFriendlyURL(request.url)}' returned a response with ` + `status '${fetchResponse.status}'.`);
}
for (const plugin of plugins) {
if (pluginEvents.FETCH_DID_SUCCEED in plugin) {
fetchResponse = await plugin[pluginEvents.FETCH_DID_SUCCEED].call(plugin, {
event,
request: pluginFilteredRequest,
response: fetchResponse
});
{
if (fetchResponse) {
finalAssertExports.isInstance(fetchResponse, Response, {
moduleName: 'Plugin',
funcName: pluginEvents.FETCH_DID_SUCCEED,
isReturnValueProblem: true
});
}
}
}
}
return fetchResponse;
} catch (error) {
{
logger.error(`Network request for ` + `'${getFriendlyURL(request.url)}' threw an error.`, error);
}
for (const plugin of failedFetchPlugins) {
await plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {
error,
event,
originalRequest: originalRequest.clone(),
request: pluginFilteredRequest.clone()
});
}
throw error;
}
};
const fetchWrapper = {
fetch: wrappedFetch
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
var _private = /*#__PURE__*/Object.freeze({
assert: finalAssertExports,
cacheNames: cacheNames,
cacheWrapper: cacheWrapper,
DBWrapper: DBWrapper,
Deferred: Deferred,
deleteDatabase: deleteDatabase,
executeQuotaErrorCallbacks: executeQuotaErrorCallbacks,
fetchWrapper: fetchWrapper,
getFriendlyURL: getFriendlyURL,
logger: logger,
WorkboxError: WorkboxError
});
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Claim any currently available clients once the service worker
* becomes active. This is normally used in conjunction with `skipWaiting()`.
*
* @alias workbox.core.clientsClaim
*/
const clientsClaim = () => {
addEventListener('activate', () => clients.claim());
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Get the current cache names and prefix/suffix used by Workbox.
*
* `cacheNames.precache` is used for precached assets,
* `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to
* store `analytics.js`, and `cacheNames.runtime` is used for everything else.
*
* `cacheNames.prefix` can be used to retrieve just the current prefix value.
* `cacheNames.suffix` can be used to retrieve just the current suffix value.
*
* @return {Object} An object with `precache`, `runtime`, `prefix`, and
* `googleAnalytics` properties.
*
* @alias workbox.core.cacheNames
*/
const cacheNames$1 = {
get googleAnalytics() {
return cacheNames.getGoogleAnalyticsName();
},
get precache() {
return cacheNames.getPrecacheName();
},
get prefix() {
return cacheNames.getPrefix();
},
get runtime() {
return cacheNames.getRuntimeName();
},
get suffix() {
return cacheNames.getSuffix();
}
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Modifies the default cache names used by the Workbox packages.
* Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
*
* @param {Object} details
* @param {Object} [details.prefix] The string to add to the beginning of
* the precache and runtime cache names.
* @param {Object} [details.suffix] The string to add to the end of
* the precache and runtime cache names.
* @param {Object} [details.precache] The cache name to use for precache
* caching.
* @param {Object} [details.runtime] The cache name to use for runtime caching.
* @param {Object} [details.googleAnalytics] The cache name to use for
* `workbox-google-analytics` caching.
*
* @alias workbox.core.setCacheNameDetails
*/
const setCacheNameDetails = details => {
{
Object.keys(details).forEach(key => {
finalAssertExports.isType(details[key], 'string', {
moduleName: 'workbox-core',
funcName: 'setCacheNameDetails',
paramName: `details.${key}`
});
});
if ('precache' in details && details.precache.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'precache',
value: details.precache
});
}
if ('runtime' in details && details.runtime.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'runtime',
value: details.runtime
});
}
if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {
throw new WorkboxError('invalid-cache-name', {
cacheNameId: 'googleAnalytics',
value: details.googleAnalytics
});
}
}
cacheNames.updateDetails(details);
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Force a service worker to become active, instead of waiting. This is
* normally used in conjunction with `clientsClaim()`.
*
* @alias workbox.core.skipWaiting
*/
const skipWaiting = () => {
// We need to explicitly call `self.skipWaiting()` here because we're
// shadowing `skipWaiting` with this local function.
addEventListener('install', () => self.skipWaiting());
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
try {
self.workbox.v = self.workbox.v || {};
} catch (errer) {} // NOOP
exports._private = _private;
exports.clientsClaim = clientsClaim;
exports.cacheNames = cacheNames$1;
exports.registerQuotaErrorCallback = registerQuotaErrorCallback;
exports.setCacheNameDetails = setCacheNameDetails;
exports.skipWaiting = skipWaiting;
return exports;
}({}));
//# sourceMappingURL=workbox-core.dev.js.map
{"version":3,"file":"workbox-core.dev.js","sources":["../_version.mjs","../_private/logger.mjs","../models/messages/messages.mjs","../models/messages/messageGenerator.mjs","../_private/WorkboxError.mjs","../_private/assert.mjs","../models/quotaErrorCallbacks.mjs","../registerQuotaErrorCallback.mjs","../_private/cacheNames.mjs","../_private/getFriendlyURL.mjs","../_private/executeQuotaErrorCallbacks.mjs","../models/pluginEvents.mjs","../utils/pluginUtils.mjs","../_private/cacheWrapper.mjs","../_private/DBWrapper.mjs","../_private/Deferred.mjs","../_private/deleteDatabase.mjs","../_private/fetchWrapper.mjs","../_private.mjs","../clientsClaim.mjs","../cacheNames.mjs","../setCacheNameDetails.mjs","../skipWaiting.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst logger = process.env.NODE_ENV === 'production' ? null : (() => {\n let inGroup = false;\n\n const methodToColorMap = {\n debug: `#7f8c8d`, // Gray\n log: `#2ecc71`, // Green\n warn: `#f39c12`, // Yellow\n error: `#c0392b`, // Red\n groupCollapsed: `#3498db`, // Blue\n groupEnd: null, // No colored prefix on groupEnd\n };\n\n const print = function(method, args) {\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n\n console[method](...logPrefix, ...args);\n\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n\n const api = {};\n for (const method of Object.keys(methodToColorMap)) {\n api[method] = (...args) => {\n print(method, args);\n };\n }\n\n return api;\n})();\n\nexport {logger};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../../_version.mjs';\n\n\nexport const messages = {\n 'invalid-value': ({paramName, validValueDescription, value}) => {\n if (!paramName || !validValueDescription) {\n throw new Error(`Unexpected input to 'invalid-value' error.`);\n }\n return `The '${paramName}' parameter was given a value with an ` +\n `unexpected value. ${validValueDescription} Received a value of ` +\n `${JSON.stringify(value)}.`;\n },\n\n 'not-in-sw': ({moduleName}) => {\n if (!moduleName) {\n throw new Error(`Unexpected input to 'not-in-sw' error.`);\n }\n return `The '${moduleName}' must be used in a service worker.`;\n },\n\n 'not-an-array': ({moduleName, className, funcName, paramName}) => {\n if (!moduleName || !className || !funcName || !paramName) {\n throw new Error(`Unexpected input to 'not-an-array' error.`);\n }\n return `The parameter '${paramName}' passed into ` +\n `'${moduleName}.${className}.${funcName}()' must be an array.`;\n },\n\n 'incorrect-type': ({expectedType, paramName, moduleName, className,\n funcName}) => {\n if (!expectedType || !paramName || !moduleName || !funcName) {\n throw new Error(`Unexpected input to 'incorrect-type' error.`);\n }\n return `The parameter '${paramName}' passed into ` +\n `'${moduleName}.${className ? (className + '.') : ''}` +\n `${funcName}()' must be of type ${expectedType}.`;\n },\n\n 'incorrect-class': ({expectedClass, paramName, moduleName, className,\n funcName, isReturnValueProblem}) => {\n if (!expectedClass || !moduleName || !funcName) {\n throw new Error(`Unexpected input to 'incorrect-class' error.`);\n }\n\n if (isReturnValueProblem) {\n return `The return value from ` +\n `'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +\n `must be an instance of class ${expectedClass.name}.`;\n }\n\n return `The parameter '${paramName}' passed into ` +\n `'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` +\n `must be an instance of class ${expectedClass.name}.`;\n },\n\n 'missing-a-method': ({expectedMethod, paramName, moduleName, className,\n funcName}) => {\n if (!expectedMethod || !paramName || !moduleName || !className\n || !funcName) {\n throw new Error(`Unexpected input to 'missing-a-method' error.`);\n }\n return `${moduleName}.${className}.${funcName}() expected the ` +\n `'${paramName}' parameter to expose a '${expectedMethod}' method.`;\n },\n\n 'add-to-cache-list-unexpected-type': ({entry}) => {\n return `An unexpected entry was passed to ` +\n `'workbox-precaching.PrecacheController.addToCacheList()' The entry ` +\n `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` +\n `strings with one or more characters, objects with a url property or ` +\n `Request objects.`;\n },\n\n 'add-to-cache-list-conflicting-entries': ({firstEntry, secondEntry}) => {\n if (!firstEntry || !secondEntry) {\n throw new Error(`Unexpected input to ` +\n `'add-to-cache-list-duplicate-entries' error.`);\n }\n\n return `Two of the entries passed to ` +\n `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` +\n `${firstEntry._entryId} but different revision details. Workbox is ` +\n `is unable to cache and version the asset correctly. Please remove one ` +\n `of the entries.`;\n },\n\n 'plugin-error-request-will-fetch': ({thrownError}) => {\n if (!thrownError) {\n throw new Error(`Unexpected input to ` +\n `'plugin-error-request-will-fetch', error.`);\n }\n\n return `An error was thrown by a plugins 'requestWillFetch()' method. ` +\n `The thrown error message was: '${thrownError.message}'.`;\n },\n\n 'invalid-cache-name': ({cacheNameId, value}) => {\n if (!cacheNameId) {\n throw new Error(\n `Expected a 'cacheNameId' for error 'invalid-cache-name'`);\n }\n\n return `You must provide a name containing at least one character for ` +\n `setCacheDeatils({${cacheNameId}: '...'}). Received a value of ` +\n `'${JSON.stringify(value)}'`;\n },\n\n 'unregister-route-but-not-found-with-method': ({method}) => {\n if (!method) {\n throw new Error(`Unexpected input to ` +\n `'unregister-route-but-not-found-with-method' error.`);\n }\n\n return `The route you're trying to unregister was not previously ` +\n `registered for the method type '${method}'.`;\n },\n\n 'unregister-route-route-not-registered': () => {\n return `The route you're trying to unregister was not previously ` +\n `registered.`;\n },\n\n 'queue-replay-failed': ({name}) => {\n return `Replaying the background sync queue '${name}' failed.`;\n },\n\n 'duplicate-queue-name': ({name}) => {\n return `The Queue name '${name}' is already being used. ` +\n `All instances of backgroundSync.Queue must be given unique names.`;\n },\n\n 'expired-test-without-max-age': ({methodName, paramName}) => {\n return `The '${methodName}()' method can only be used when the ` +\n `'${paramName}' is used in the constructor.`;\n },\n\n 'unsupported-route-type': ({moduleName, className, funcName, paramName}) => {\n return `The supplied '${paramName}' parameter was an unsupported type. ` +\n `Please check the docs for ${moduleName}.${className}.${funcName} for ` +\n `valid input types.`;\n },\n\n 'not-array-of-class': ({value, expectedClass,\n moduleName, className, funcName, paramName}) => {\n return `The supplied '${paramName}' parameter must be an array of ` +\n `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` +\n `Please check the call to ${moduleName}.${className}.${funcName}() ` +\n `to fix the issue.`;\n },\n\n 'max-entries-or-age-required': ({moduleName, className, funcName}) => {\n return `You must define either config.maxEntries or config.maxAgeSeconds` +\n `in ${moduleName}.${className}.${funcName}`;\n },\n\n 'statuses-or-headers-required': ({moduleName, className, funcName}) => {\n return `You must define either config.statuses or config.headers` +\n `in ${moduleName}.${className}.${funcName}`;\n },\n\n 'invalid-string': ({moduleName, className, funcName, paramName}) => {\n if (!paramName || !moduleName || !funcName) {\n throw new Error(`Unexpected input to 'invalid-string' error.`);\n }\n return `When using strings, the '${paramName}' parameter must start with ` +\n `'http' (for cross-origin matches) or '/' (for same-origin matches). ` +\n `Please see the docs for ${moduleName}.${funcName}() for ` +\n `more info.`;\n },\n\n 'channel-name-required': () => {\n return `You must provide a channelName to construct a ` +\n `BroadcastCacheUpdate instance.`;\n },\n\n 'invalid-responses-are-same-args': () => {\n return `The arguments passed into responsesAreSame() appear to be ` +\n `invalid. Please ensure valid Responses are used.`;\n },\n\n 'expire-custom-caches-only': () => {\n return `You must provide a 'cacheName' property when using the ` +\n `expiration plugin with a runtime caching strategy.`;\n },\n\n 'unit-must-be-bytes': ({normalizedRangeHeader}) => {\n if (!normalizedRangeHeader) {\n throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`);\n }\n return `The 'unit' portion of the Range header must be set to 'bytes'. ` +\n `The Range header provided was \"${normalizedRangeHeader}\"`;\n },\n\n 'single-range-only': ({normalizedRangeHeader}) => {\n if (!normalizedRangeHeader) {\n throw new Error(`Unexpected input to 'single-range-only' error.`);\n }\n return `Multiple ranges are not supported. Please use a single start ` +\n `value, and optional end value. The Range header provided was ` +\n `\"${normalizedRangeHeader}\"`;\n },\n\n 'invalid-range-values': ({normalizedRangeHeader}) => {\n if (!normalizedRangeHeader) {\n throw new Error(`Unexpected input to 'invalid-range-values' error.`);\n }\n return `The Range header is missing both start and end values. At least ` +\n `one of those values is needed. The Range header provided was ` +\n `\"${normalizedRangeHeader}\"`;\n },\n\n 'no-range-header': () => {\n return `No Range header was found in the Request provided.`;\n },\n\n 'range-not-satisfiable': ({size, start, end}) => {\n return `The start (${start}) and end (${end}) values in the Range are ` +\n `not satisfiable by the cached response, which is ${size} bytes.`;\n },\n\n 'attempt-to-cache-non-get-request': ({url, method}) => {\n return `Unable to cache '${url}' because it is a '${method}' request and ` +\n `only 'GET' requests can be cached.`;\n },\n\n 'cache-put-with-no-response': ({url}) => {\n return `There was an attempt to cache '${url}' but the response was not ` +\n `defined.`;\n },\n\n 'no-response': ({url, error}) => {\n let message = `The strategy could not generate a response for '${url}'.`;\n if (error) {\n message += ` The underlying error is ${error}.`;\n }\n return message;\n },\n\n 'bad-precaching-response': ({url, status}) => {\n return `The precaching request for '${url}' failed with an HTTP ` +\n `status of ${status}.`;\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messages} from './messages.mjs';\nimport '../../_version.mjs';\n\nconst fallback = (code, ...args) => {\n let msg = code;\n if (args.length > 0) {\n msg += ` :: ${JSON.stringify(args)}`;\n }\n return msg;\n};\n\nconst generatorFunction = (code, ...args) => {\n const message = messages[code];\n if (!message) {\n throw new Error(`Unable to find message for code '${code}'.`);\n }\n\n return message(...args);\n};\n\nexport const messageGenerator = (process.env.NODE_ENV === 'production') ?\n fallback : generatorFunction;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messageGenerator} from '../models/messages/messageGenerator.mjs';\nimport '../_version.mjs';\n\n/**\n * Workbox errors should be thrown with this class.\n * This allows use to ensure the type easily in tests,\n * helps developers identify errors from workbox\n * easily and allows use to optimise error\n * messages correctly.\n *\n * @private\n */\nclass WorkboxError extends Error {\n /**\n *\n * @param {string} errorCode The error code that\n * identifies this particular error.\n * @param {Object=} details Any relevant arguments\n * that will help developers identify issues should\n * be added as a key on the context object.\n */\n constructor(errorCode, details) {\n let message = messageGenerator(errorCode, details);\n\n super(message);\n\n this.name = errorCode;\n this.details = details;\n }\n}\n\nexport {WorkboxError};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from '../_private/WorkboxError.mjs';\nimport '../_version.mjs';\n\n/*\n * This method returns true if the current context is a service worker.\n */\nconst isSWEnv = (moduleName) => {\n if (!('ServiceWorkerGlobalScope' in self)) {\n throw new WorkboxError('not-in-sw', {moduleName});\n }\n};\n\n/*\n * This method throws if the supplied value is not an array.\n * The destructed values are required to produce a meaningful error for users.\n * The destructed and restructured object is so it's clear what is\n * needed.\n */\nconst isArray = (value, {moduleName, className, funcName, paramName}) => {\n if (!Array.isArray(value)) {\n throw new WorkboxError('not-an-array', {\n moduleName,\n className,\n funcName,\n paramName,\n });\n }\n};\n\nconst hasMethod = (object, expectedMethod,\n {moduleName, className, funcName, paramName}) => {\n const type = typeof object[expectedMethod];\n if (type !== 'function') {\n throw new WorkboxError('missing-a-method', {paramName, expectedMethod,\n moduleName, className, funcName});\n }\n};\n\nconst isType = (object, expectedType,\n {moduleName, className, funcName, paramName}) => {\n if (typeof object !== expectedType) {\n throw new WorkboxError('incorrect-type', {paramName, expectedType,\n moduleName, className, funcName});\n }\n};\n\nconst isInstance = (object, expectedClass,\n {moduleName, className, funcName,\n paramName, isReturnValueProblem}) => {\n if (!(object instanceof expectedClass)) {\n throw new WorkboxError('incorrect-class', {paramName, expectedClass,\n moduleName, className, funcName, isReturnValueProblem});\n }\n};\n\nconst isOneOf = (value, validValues, {paramName}) => {\n if (!validValues.includes(value)) {\n throw new WorkboxError('invalid-value', {\n paramName,\n value,\n validValueDescription: `Valid values are ${JSON.stringify(validValues)}.`,\n });\n }\n};\n\nconst isArrayOfClass = (value, expectedClass,\n {moduleName, className, funcName, paramName}) => {\n const error = new WorkboxError('not-array-of-class', {\n value, expectedClass,\n moduleName, className, funcName, paramName,\n });\n if (!Array.isArray(value)) {\n throw error;\n }\n\n for (let item of value) {\n if (!(item instanceof expectedClass)) {\n throw error;\n }\n }\n};\n\nconst finalAssertExports = process.env.NODE_ENV === 'production' ? null : {\n hasMethod,\n isArray,\n isInstance,\n isOneOf,\n isSWEnv,\n isType,\n isArrayOfClass,\n};\n\nexport {finalAssertExports as assert};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n// Callbacks to be executed whenever there's a quota error.\nconst quotaErrorCallbacks = new Set();\n\nexport {quotaErrorCallbacks};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from './_private/logger.mjs';\nimport {assert} from './_private/assert.mjs';\nimport {quotaErrorCallbacks} from './models/quotaErrorCallbacks.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds a function to the set of quotaErrorCallbacks that will be executed if\n * there's a quota error.\n *\n * @param {Function} callback\n * @memberof workbox.core\n */\nfunction registerQuotaErrorCallback(callback) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(callback, 'function', {\n moduleName: 'workbox-core',\n funcName: 'register',\n paramName: 'callback',\n });\n }\n\n quotaErrorCallbacks.add(callback);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered a callback to respond to quota errors.', callback);\n }\n}\n\nexport {registerQuotaErrorCallback};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst _cacheNameDetails = {\n googleAnalytics: 'googleAnalytics',\n precache: 'precache-v2',\n prefix: 'workbox',\n runtime: 'runtime',\n suffix: self.registration.scope,\n};\n\nconst _createCacheName = (cacheName) => {\n return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix]\n .filter((value) => value.length > 0)\n .join('-');\n};\n\nexport const cacheNames = {\n updateDetails: (details) => {\n Object.keys(_cacheNameDetails).forEach((key) => {\n if (typeof details[key] !== 'undefined') {\n _cacheNameDetails[key] = details[key];\n }\n });\n },\n getGoogleAnalyticsName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);\n },\n getPrecacheName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.precache);\n },\n getPrefix: () => {\n return _cacheNameDetails.prefix;\n },\n getRuntimeName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.runtime);\n },\n getSuffix: () => {\n return _cacheNameDetails.suffix;\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst getFriendlyURL = (url) => {\n const urlObj = new URL(url, location);\n if (urlObj.origin === location.origin) {\n return urlObj.pathname;\n }\n return urlObj.href;\n};\n\nexport {getFriendlyURL};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from '../_private/logger.mjs';\nimport {quotaErrorCallbacks} from '../models/quotaErrorCallbacks.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Runs all of the callback functions, one at a time sequentially, in the order\n * in which they were registered.\n *\n * @memberof workbox.core\n * @private\n */\nasync function executeQuotaErrorCallbacks() {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`About to run ${quotaErrorCallbacks.size} ` +\n `callbacks to clean up caches.`);\n }\n\n for (const callback of quotaErrorCallbacks) {\n await callback();\n if (process.env.NODE_ENV !== 'production') {\n logger.log(callback, 'is complete.');\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Finished running callbacks.');\n }\n}\n\nexport {executeQuotaErrorCallbacks};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nexport const pluginEvents = {\n CACHE_DID_UPDATE: 'cacheDidUpdate',\n CACHE_KEY_WILL_BE_USED: 'cacheKeyWillBeUsed',\n CACHE_WILL_UPDATE: 'cacheWillUpdate',\n CACHED_RESPONSE_WILL_BE_USED: 'cachedResponseWillBeUsed',\n FETCH_DID_FAIL: 'fetchDidFail',\n FETCH_DID_SUCCEED: 'fetchDidSucceed',\n REQUEST_WILL_FETCH: 'requestWillFetch',\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const pluginUtils = {\n filter: (plugins, callbackName) => {\n return plugins.filter((plugin) => callbackName in plugin);\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from './WorkboxError.mjs';\nimport {assert} from './assert.mjs';\nimport {getFriendlyURL} from './getFriendlyURL.mjs';\nimport {logger} from './logger.mjs';\nimport {executeQuotaErrorCallbacks} from './executeQuotaErrorCallbacks.mjs';\nimport {pluginEvents} from '../models/pluginEvents.mjs';\nimport {pluginUtils} from '../utils/pluginUtils.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Wrapper around cache.put().\n *\n * Will call `cacheDidUpdate` on plugins if the cache was updated, using\n * `matchOptions` when determining what the old entry is.\n *\n * @param {Object} options\n * @param {string} options.cacheName\n * @param {Request} options.request\n * @param {Response} options.response\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @param {Object} [options.matchOptions]\n *\n * @private\n * @memberof module:workbox-core\n */\nconst putWrapper = async ({\n cacheName,\n request,\n response,\n event,\n plugins = [],\n matchOptions,\n} = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n if (request.method && request.method !== 'GET') {\n throw new WorkboxError('attempt-to-cache-non-get-request', {\n url: getFriendlyURL(request.url),\n method: request.method,\n });\n }\n }\n\n const effectiveRequest = await _getEffectiveRequest({\n plugins, request, mode: 'write'});\n\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Cannot cache non-existent response for ` +\n `'${getFriendlyURL(effectiveRequest.url)}'.`);\n }\n\n throw new WorkboxError('cache-put-with-no-response', {\n url: getFriendlyURL(effectiveRequest.url),\n });\n }\n\n let responseToCache = await _isResponseSafeToCache({\n event,\n plugins,\n response,\n request: effectiveRequest,\n });\n\n if (!responseToCache) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Response '${getFriendlyURL(effectiveRequest.url)}' will ` +\n `not be cached.`, responseToCache);\n }\n return;\n }\n\n const cache = await caches.open(cacheName);\n\n const updatePlugins = pluginUtils.filter(\n plugins, pluginEvents.CACHE_DID_UPDATE);\n\n let oldResponse = updatePlugins.length > 0 ?\n await matchWrapper({cacheName, matchOptions, request: effectiveRequest}) :\n null;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Updating the '${cacheName}' cache with a new Response for ` +\n `${getFriendlyURL(effectiveRequest.url)}.`);\n }\n\n try {\n await cache.put(effectiveRequest, responseToCache);\n } catch (error) {\n // See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError\n if (error.name === 'QuotaExceededError') {\n await executeQuotaErrorCallbacks();\n }\n throw error;\n }\n\n for (let plugin of updatePlugins) {\n await plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {\n cacheName,\n event,\n oldResponse,\n newResponse: responseToCache,\n request: effectiveRequest,\n });\n }\n};\n\n/**\n * This is a wrapper around cache.match().\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache to match against.\n * @param {Request} options.request The Request that will be used to look up\n * cache entries.\n * @param {Event} [options.event] The event that propted the action.\n * @param {Object} [options.matchOptions] Options passed to cache.match().\n * @param {Array<Object>} [options.plugins=[]] Array of plugins.\n * @return {Response} A cached response if available.\n *\n * @private\n * @memberof module:workbox-core\n */\nconst matchWrapper = async ({\n cacheName,\n request,\n event,\n matchOptions,\n plugins = [],\n}) => {\n const cache = await caches.open(cacheName);\n\n const effectiveRequest = await _getEffectiveRequest({\n plugins, request, mode: 'read'});\n\n let cachedResponse = await cache.match(effectiveRequest, matchOptions);\n if (process.env.NODE_ENV !== 'production') {\n if (cachedResponse) {\n logger.debug(`Found a cached response in '${cacheName}'.`);\n } else {\n logger.debug(`No cached response found in '${cacheName}'.`);\n }\n }\n\n for (const plugin of plugins) {\n if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {\n cachedResponse = await plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED]\n .call(plugin, {\n cacheName,\n event,\n matchOptions,\n cachedResponse,\n request: effectiveRequest,\n });\n if (process.env.NODE_ENV !== 'production') {\n if (cachedResponse) {\n assert.isInstance(cachedResponse, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n\n return cachedResponse;\n};\n\n/**\n * This method will call cacheWillUpdate on the available plugins (or use\n * status === 200) to determine if the Response is safe and valid to cache.\n *\n * @param {Object} options\n * @param {Request} options.request\n * @param {Response} options.response\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Response>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst _isResponseSafeToCache = async ({request, response, event, plugins}) => {\n let responseToCache = response;\n let pluginsUsed = false;\n for (let plugin of plugins) {\n if (pluginEvents.CACHE_WILL_UPDATE in plugin) {\n pluginsUsed = true;\n responseToCache = await plugin[pluginEvents.CACHE_WILL_UPDATE]\n .call(plugin, {\n request,\n response: responseToCache,\n event,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (responseToCache) {\n assert.isInstance(responseToCache, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHE_WILL_UPDATE,\n isReturnValueProblem: true,\n });\n }\n }\n\n if (!responseToCache) {\n break;\n }\n }\n }\n\n if (!pluginsUsed) {\n if (process.env.NODE_ENV !== 'production') {\n if (!responseToCache.status === 200) {\n if (responseToCache.status === 0) {\n logger.warn(`The response for '${request.url}' is an opaque ` +\n `response. The caching strategy that you're using will not ` +\n `cache opaque responses by default.`);\n } else {\n logger.debug(`The response for '${request.url}' returned ` +\n `a status code of '${response.status}' and won't be cached as a ` +\n `result.`);\n }\n }\n }\n responseToCache = responseToCache.status === 200 ? responseToCache : null;\n }\n\n return responseToCache ? responseToCache : null;\n};\n\n/**\n * Checks the list of plugins for the cacheKeyWillBeUsed callback, and\n * executes any of those callbacks found in sequence. The final `Request` object\n * returned by the last plugin is treated as the cache key for cache reads\n * and/or writes.\n *\n * @param {Object} options\n * @param {Request} options.request\n * @param {string} options.mode\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Request>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst _getEffectiveRequest = async ({request, mode, plugins}) => {\n const cacheKeyWillBeUsedPlugins = pluginUtils.filter(\n plugins, pluginEvents.CACHE_KEY_WILL_BE_USED);\n\n let effectiveRequest = request;\n for (const plugin of cacheKeyWillBeUsedPlugins) {\n effectiveRequest = await plugin[pluginEvents.CACHE_KEY_WILL_BE_USED].call(\n plugin, {mode, request: effectiveRequest});\n\n if (typeof effectiveRequest === 'string') {\n effectiveRequest = new Request(effectiveRequest);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(effectiveRequest, Request, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHE_KEY_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n\n return effectiveRequest;\n};\n\nexport const cacheWrapper = {\n put: putWrapper,\n match: matchWrapper,\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A class that wraps common IndexedDB functionality in a promise-based API.\n * It exposes all the underlying power and functionality of IndexedDB, but\n * wraps the most commonly used features in a way that's much simpler to use.\n *\n * @private\n */\nexport class DBWrapper {\n /**\n * @param {string} name\n * @param {number} version\n * @param {Object=} [callback]\n * @param {!Function} [callbacks.onupgradeneeded]\n * @param {!Function} [callbacks.onversionchange] Defaults to\n * DBWrapper.prototype._onversionchange when not specified.\n * @private\n */\n constructor(name, version, {\n onupgradeneeded,\n onversionchange = this._onversionchange,\n } = {}) {\n this._name = name;\n this._version = version;\n this._onupgradeneeded = onupgradeneeded;\n this._onversionchange = onversionchange;\n\n // If this is null, it means the database isn't open.\n this._db = null;\n }\n\n /**\n * Returns the IDBDatabase instance (not normally needed).\n *\n * @private\n */\n get db() {\n return this._db;\n }\n\n /**\n * Opens a connected to an IDBDatabase, invokes any onupgradedneeded\n * callback, and added an onversionchange callback to the database.\n *\n * @return {IDBDatabase}\n * @private\n */\n async open() {\n if (this._db) return;\n\n this._db = await new Promise((resolve, reject) => {\n // This flag is flipped to true if the timeout callback runs prior\n // to the request failing or succeeding. Note: we use a timeout instead\n // of an onblocked handler since there are cases where onblocked will\n // never never run. A timeout better handles all possible scenarios:\n // https://github.com/w3c/IndexedDB/issues/223\n let openRequestTimedOut = false;\n setTimeout(() => {\n openRequestTimedOut = true;\n reject(new Error('The open request was blocked and timed out'));\n }, this.OPEN_TIMEOUT);\n\n const openRequest = indexedDB.open(this._name, this._version);\n openRequest.onerror = () => reject(openRequest.error);\n openRequest.onupgradeneeded = (evt) => {\n if (openRequestTimedOut) {\n openRequest.transaction.abort();\n evt.target.result.close();\n } else if (this._onupgradeneeded) {\n this._onupgradeneeded(evt);\n }\n };\n openRequest.onsuccess = ({target}) => {\n const db = target.result;\n if (openRequestTimedOut) {\n db.close();\n } else {\n db.onversionchange = this._onversionchange.bind(this);\n resolve(db);\n }\n };\n });\n\n return this;\n }\n\n /**\n * Polyfills the native `getKey()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @return {Array}\n * @private\n */\n async getKey(storeName, query) {\n return (await this.getAllKeys(storeName, query, 1))[0];\n }\n\n /**\n * Polyfills the native `getAll()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @param {number} count\n * @return {Array}\n * @private\n */\n async getAll(storeName, query, count) {\n return await this.getAllMatching(storeName, {query, count});\n }\n\n\n /**\n * Polyfills the native `getAllKeys()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @param {number} count\n * @return {Array}\n * @private\n */\n async getAllKeys(storeName, query, count) {\n return (await this.getAllMatching(\n storeName, {query, count, includeKeys: true})).map(({key}) => key);\n }\n\n /**\n * Supports flexible lookup in an object store by specifying an index,\n * query, direction, and count. This method returns an array of objects\n * with the signature .\n *\n * @param {string} storeName\n * @param {Object} [opts]\n * @param {string} [opts.index] The index to use (if specified).\n * @param {*} [opts.query]\n * @param {IDBCursorDirection} [opts.direction]\n * @param {number} [opts.count] The max number of results to return.\n * @param {boolean} [opts.includeKeys] When true, the structure of the\n * returned objects is changed from an array of values to an array of\n * objects in the form {key, primaryKey, value}.\n * @return {Array}\n * @private\n */\n async getAllMatching(storeName, {\n index,\n query = null, // IE errors if query === `undefined`.\n direction = 'next',\n count,\n includeKeys,\n } = {}) {\n return await this.transaction([storeName], 'readonly', (txn, done) => {\n const store = txn.objectStore(storeName);\n const target = index ? store.index(index) : store;\n const results = [];\n\n target.openCursor(query, direction).onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const {primaryKey, key, value} = cursor;\n results.push(includeKeys ? {primaryKey, key, value} : value);\n if (count && results.length >= count) {\n done(results);\n } else {\n cursor.continue();\n }\n } else {\n done(results);\n }\n };\n });\n }\n\n /**\n * Accepts a list of stores, a transaction type, and a callback and\n * performs a transaction. A promise is returned that resolves to whatever\n * value the callback chooses. The callback holds all the transaction logic\n * and is invoked with two arguments:\n * 1. The IDBTransaction object\n * 2. A `done` function, that's used to resolve the promise when\n * when the transaction is done, if passed a value, the promise is\n * resolved to that value.\n *\n * @param {Array<string>} storeNames An array of object store names\n * involved in the transaction.\n * @param {string} type Can be `readonly` or `readwrite`.\n * @param {!Function} callback\n * @return {*} The result of the transaction ran by the callback.\n * @private\n */\n async transaction(storeNames, type, callback) {\n await this.open();\n return await new Promise((resolve, reject) => {\n const txn = this._db.transaction(storeNames, type);\n txn.onabort = ({target}) => reject(target.error);\n txn.oncomplete = () => resolve();\n\n callback(txn, (value) => resolve(value));\n });\n }\n\n /**\n * Delegates async to a native IDBObjectStore method.\n *\n * @param {string} method The method name.\n * @param {string} storeName The object store name.\n * @param {string} type Can be `readonly` or `readwrite`.\n * @param {...*} args The list of args to pass to the native method.\n * @return {*} The result of the transaction.\n * @private\n */\n async _call(method, storeName, type, ...args) {\n const callback = (txn, done) => {\n txn.objectStore(storeName)[method](...args).onsuccess = ({target}) => {\n done(target.result);\n };\n };\n\n return await this.transaction([storeName], type, callback);\n }\n\n /**\n * The default onversionchange handler, which closes the database so other\n * connections can open without being blocked.\n *\n * @private\n */\n _onversionchange() {\n this.close();\n }\n\n /**\n * Closes the connection opened by `DBWrapper.open()`. Generally this method\n * doesn't need to be called since:\n * 1. It's usually better to keep a connection open since opening\n * a new connection is somewhat slow.\n * 2. Connections are automatically closed when the reference is\n * garbage collected.\n * The primary use case for needing to close a connection is when another\n * reference (typically in another tab) needs to upgrade it and would be\n * blocked by the current, open connection.\n *\n * @private\n */\n close() {\n if (this._db) {\n this._db.close();\n this._db = null;\n }\n }\n}\n\n// Exposed to let users modify the default timeout on a per-instance\n// or global basis.\nDBWrapper.prototype.OPEN_TIMEOUT = 2000;\n\n// Wrap native IDBObjectStore methods according to their mode.\nconst methodsToWrap = {\n 'readonly': ['get', 'count', 'getKey', 'getAll', 'getAllKeys'],\n 'readwrite': ['add', 'put', 'clear', 'delete'],\n};\nfor (const [mode, methods] of Object.entries(methodsToWrap)) {\n for (const method of methods) {\n if (method in IDBObjectStore.prototype) {\n // Don't use arrow functions here since we're outside of the class.\n DBWrapper.prototype[method] = async function(storeName, ...args) {\n return await this._call(method, storeName, mode, ...args);\n };\n }\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Deletes the database.\n * Note: this is exported separately from the DBWrapper module because most\n * usages of IndexedDB in workbox dont need deleting, and this way it can be\n * reused in tests to delete databases without creating DBWrapper instances.\n *\n * @param {string} name The database name.\n * @private\n */\nexport const deleteDatabase = async (name) => {\n await new Promise((resolve, reject) => {\n const request = indexedDB.deleteDatabase(name);\n request.onerror = ({target}) => {\n reject(target.error);\n };\n request.onblocked = () => {\n reject(new Error('Delete blocked'));\n };\n request.onsuccess = () => {\n resolve();\n };\n });\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from './WorkboxError.mjs';\nimport {logger} from './logger.mjs';\nimport {assert} from './assert.mjs';\nimport {getFriendlyURL} from '../_private/getFriendlyURL.mjs';\nimport {pluginEvents} from '../models/pluginEvents.mjs';\nimport {pluginUtils} from '../utils/pluginUtils.mjs';\nimport '../_version.mjs';\n\n/**\n * Wrapper around the fetch API.\n *\n * Will call requestWillFetch on available plugins.\n *\n * @param {Object} options\n * @param {Request|string} options.request\n * @param {Object} [options.fetchOptions]\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Response>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst wrappedFetch = async ({\n request,\n fetchOptions,\n event,\n plugins = []}) => {\n // We *should* be able to call `await event.preloadResponse` even if it's\n // undefined, but for some reason, doing so leads to errors in our Node unit\n // tests. To work around that, explicitly check preloadResponse's value first.\n if (event && event.preloadResponse) {\n const possiblePreloadResponse = await event.preloadResponse;\n if (possiblePreloadResponse) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Using a preloaded navigation response for ` +\n `'${getFriendlyURL(request.url)}'`);\n }\n return possiblePreloadResponse;\n }\n }\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n paramName: request,\n expectedClass: 'Request',\n moduleName: 'workbox-core',\n className: 'fetchWrapper',\n funcName: 'wrappedFetch',\n });\n }\n\n const failedFetchPlugins = pluginUtils.filter(\n plugins, pluginEvents.FETCH_DID_FAIL);\n\n // If there is a fetchDidFail plugin, we need to save a clone of the\n // original request before it's either modified by a requestWillFetch\n // plugin or before the original request's body is consumed via fetch().\n const originalRequest = failedFetchPlugins.length > 0 ?\n request.clone() : null;\n\n try {\n for (let plugin of plugins) {\n if (pluginEvents.REQUEST_WILL_FETCH in plugin) {\n request = await plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {\n request: request.clone(),\n event,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (request) {\n assert.isInstance(request, Request, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n } catch (err) {\n throw new WorkboxError('plugin-error-request-will-fetch', {\n thrownError: err,\n });\n }\n\n // The request can be altered by plugins with `requestWillFetch` making\n // the original request (Most likely from a `fetch` event) to be different\n // to the Request we make. Pass both to `fetchDidFail` to aid debugging.\n let pluginFilteredRequest = request.clone();\n\n try {\n let fetchResponse;\n\n // See https://github.com/GoogleChrome/workbox/issues/1796\n if (request.mode === 'navigate') {\n fetchResponse = await fetch(request);\n } else {\n fetchResponse = await fetch(request, fetchOptions);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Network request for `+\n `'${getFriendlyURL(request.url)}' returned a response with ` +\n `status '${fetchResponse.status}'.`);\n }\n\n for (const plugin of plugins) {\n if (pluginEvents.FETCH_DID_SUCCEED in plugin) {\n fetchResponse = await plugin[pluginEvents.FETCH_DID_SUCCEED]\n .call(plugin, {\n event,\n request: pluginFilteredRequest,\n response: fetchResponse,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (fetchResponse) {\n assert.isInstance(fetchResponse, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.FETCH_DID_SUCCEED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n\n return fetchResponse;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Network request for `+\n `'${getFriendlyURL(request.url)}' threw an error.`, error);\n }\n\n for (const plugin of failedFetchPlugins) {\n await plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {\n error,\n event,\n originalRequest: originalRequest.clone(),\n request: pluginFilteredRequest.clone(),\n });\n }\n\n throw error;\n }\n};\n\nconst fetchWrapper = {\n fetch: wrappedFetch,\n};\n\nexport {fetchWrapper};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\n// We either expose defaults or we expose every named export.\nimport {assert} from './_private/assert.mjs';\nimport {cacheNames} from './_private/cacheNames.mjs';\nimport {cacheWrapper} from './_private/cacheWrapper.mjs';\nimport {DBWrapper} from './_private/DBWrapper.mjs';\nimport {Deferred} from './_private/Deferred.mjs';\nimport {deleteDatabase} from './_private/deleteDatabase.mjs';\nimport {executeQuotaErrorCallbacks} from './_private/executeQuotaErrorCallbacks.mjs';\nimport {fetchWrapper} from './_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from './_private/getFriendlyURL.mjs';\nimport {logger} from './_private/logger.mjs';\nimport {WorkboxError} from './_private/WorkboxError.mjs';\n\nimport './_version.mjs';\n\nexport {\n assert,\n cacheNames,\n cacheWrapper,\n DBWrapper,\n Deferred,\n deleteDatabase,\n executeQuotaErrorCallbacks,\n fetchWrapper,\n getFriendlyURL,\n logger,\n WorkboxError,\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Claim any currently available clients once the service worker\n * becomes active. This is normally used in conjunction with `skipWaiting()`.\n *\n * @alias workbox.core.clientsClaim\n */\nexport const clientsClaim = () => {\n addEventListener('activate', () => clients.claim());\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames as _cacheNames} from './_private/cacheNames.mjs';\nimport './_version.mjs';\n\n\n/**\n * Get the current cache names and prefix/suffix used by Workbox.\n *\n * `cacheNames.precache` is used for precached assets,\n * `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to\n * store `analytics.js`, and `cacheNames.runtime` is used for everything else.\n *\n * `cacheNames.prefix` can be used to retrieve just the current prefix value.\n * `cacheNames.suffix` can be used to retrieve just the current suffix value.\n *\n * @return {Object} An object with `precache`, `runtime`, `prefix`, and\n * `googleAnalytics` properties.\n *\n * @alias workbox.core.cacheNames\n */\nexport const cacheNames = {\n get googleAnalytics() {\n return _cacheNames.getGoogleAnalyticsName();\n },\n get precache() {\n return _cacheNames.getPrecacheName();\n },\n get prefix() {\n return _cacheNames.getPrefix();\n },\n get runtime() {\n return _cacheNames.getRuntimeName();\n },\n get suffix() {\n return _cacheNames.getSuffix();\n },\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from './_private/assert.mjs';\nimport {cacheNames} from './_private/cacheNames.mjs';\nimport {WorkboxError} from './_private/WorkboxError.mjs';\nimport './_version.mjs';\n\n\n/**\n * Modifies the default cache names used by the Workbox packages.\n * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.\n *\n * @param {Object} details\n * @param {Object} [details.prefix] The string to add to the beginning of\n * the precache and runtime cache names.\n * @param {Object} [details.suffix] The string to add to the end of\n * the precache and runtime cache names.\n * @param {Object} [details.precache] The cache name to use for precache\n * caching.\n * @param {Object} [details.runtime] The cache name to use for runtime caching.\n * @param {Object} [details.googleAnalytics] The cache name to use for\n * `workbox-google-analytics` caching.\n *\n * @alias workbox.core.setCacheNameDetails\n */\nexport const setCacheNameDetails = (details) => {\n if (process.env.NODE_ENV !== 'production') {\n Object.keys(details).forEach((key) => {\n assert.isType(details[key], 'string', {\n moduleName: 'workbox-core',\n funcName: 'setCacheNameDetails',\n paramName: `details.${key}`,\n });\n });\n\n if ('precache' in details && details.precache.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'precache',\n value: details.precache,\n });\n }\n\n if ('runtime' in details && details.runtime.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'runtime',\n value: details.runtime,\n });\n }\n\n if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'googleAnalytics',\n value: details.googleAnalytics,\n });\n }\n }\n\n cacheNames.updateDetails(details);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Force a service worker to become active, instead of waiting. This is\n * normally used in conjunction with `clientsClaim()`.\n *\n * @alias workbox.core.skipWaiting\n */\nexport const skipWaiting = () => {\n // We need to explicitly call `self.skipWaiting()` here because we're\n // shadowing `skipWaiting` with this local function.\n addEventListener('install', () => self.skipWaiting());\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {registerQuotaErrorCallback} from './registerQuotaErrorCallback.mjs';\nimport * as _private from './_private.mjs';\nimport {clientsClaim} from './clientsClaim.mjs';\nimport {cacheNames} from './cacheNames.mjs';\nimport {setCacheNameDetails} from './setCacheNameDetails.mjs';\nimport {skipWaiting} from './skipWaiting.mjs';\nimport './_version.mjs';\n\n\n// Give our version strings something to hang off of.\ntry {\n self.workbox.v = self.workbox.v || {};\n} catch (errer) {\n // NOOP\n}\n\n/**\n * All of the Workbox service worker libraries use workbox-core for shared\n * code as well as setting default values that need to be shared (like cache\n * names).\n *\n * @namespace workbox.core\n */\n\nexport {\n _private,\n clientsClaim,\n cacheNames,\n registerQuotaErrorCallback,\n setCacheNameDetails,\n skipWaiting,\n};\n"],"names":["self","_","e","logger","process","inGroup","methodToColorMap","debug","log","warn","error","groupCollapsed","groupEnd","print","method","args","test","navigator","userAgent","console","styles","logPrefix","join","api","Object","keys","messages","paramName","validValueDescription","value","Error","JSON","stringify","moduleName","className","funcName","expectedType","expectedClass","isReturnValueProblem","name","expectedMethod","entry","firstEntry","secondEntry","_entryId","thrownError","message","cacheNameId","methodName","normalizedRangeHeader","size","start","end","url","status","generatorFunction","code","messageGenerator","WorkboxError","constructor","errorCode","details","isSWEnv","isArray","Array","hasMethod","object","type","isType","isInstance","isOneOf","validValues","includes","isArrayOfClass","item","finalAssertExports","quotaErrorCallbacks","Set","registerQuotaErrorCallback","callback","assert","add","_cacheNameDetails","googleAnalytics","precache","prefix","runtime","suffix","registration","scope","_createCacheName","cacheName","filter","length","cacheNames","updateDetails","forEach","key","getGoogleAnalyticsName","userCacheName","getPrecacheName","getPrefix","getRuntimeName","getSuffix","getFriendlyURL","urlObj","URL","location","origin","pathname","href","executeQuotaErrorCallbacks","pluginEvents","CACHE_DID_UPDATE","CACHE_KEY_WILL_BE_USED","CACHE_WILL_UPDATE","CACHED_RESPONSE_WILL_BE_USED","FETCH_DID_FAIL","FETCH_DID_SUCCEED","REQUEST_WILL_FETCH","pluginUtils","plugins","callbackName","plugin","putWrapper","request","response","event","matchOptions","effectiveRequest","_getEffectiveRequest","mode","responseToCache","_isResponseSafeToCache","cache","caches","open","updatePlugins","oldResponse","matchWrapper","put","call","newResponse","cachedResponse","match","Response","pluginsUsed","cacheKeyWillBeUsedPlugins","Request","cacheWrapper","DBWrapper","version","onupgradeneeded","onversionchange","_onversionchange","_name","_version","_onupgradeneeded","_db","db","Promise","resolve","reject","openRequestTimedOut","setTimeout","OPEN_TIMEOUT","openRequest","indexedDB","onerror","evt","transaction","abort","target","result","close","onsuccess","bind","getKey","storeName","query","getAllKeys","getAll","count","getAllMatching","includeKeys","map","index","direction","txn","done","store","objectStore","results","openCursor","cursor","primaryKey","push","continue","storeNames","onabort","oncomplete","_call","prototype","methodsToWrap","methods","entries","IDBObjectStore","Deferred","promise","deleteDatabase","onblocked","wrappedFetch","fetchOptions","preloadResponse","possiblePreloadResponse","failedFetchPlugins","originalRequest","clone","err","pluginFilteredRequest","fetchResponse","fetch","fetchWrapper","clientsClaim","addEventListener","clients","claim","_cacheNames","setCacheNameDetails","skipWaiting","workbox","v","errer"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,oBAAD,CAAJ,IAA4BC,CAAC,EAA7B;EAAgC,CAApC,CAAoC,OAAMC,CAAN,EAAQ;;ECA5C;;;;;;AAOA,EAGA,MAAMC,MAAM,GAAGC,AAA+C,CAAC,MAAM;EACnE,MAAIC,OAAO,GAAG,KAAd;EAEA,QAAMC,gBAAgB,GAAG;EACvBC,IAAAA,KAAK,EAAG,SADe;EACL;EAClBC,IAAAA,GAAG,EAAG,SAFiB;EAEP;EAChBC,IAAAA,IAAI,EAAG,SAHgB;EAGN;EACjBC,IAAAA,KAAK,EAAG,SAJe;EAIL;EAClBC,IAAAA,cAAc,EAAG,SALM;EAKI;EAC3BC,IAAAA,QAAQ,EAAE,IANa;;EAAA,GAAzB;;EASA,QAAMC,KAAK,GAAG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DW,EAAAA,UAAU,CAACC,aAAX,CAAyBlC,OAAzB;EACD,CAjCM;;EC/BP;;;;;;;AAQA,EAGA;;;;;;;AAMA,QAAawK,WAAW,GAAG,MAAM;EAC/B;EACA;EACAL,EAAAA,gBAAgB,CAAC,SAAD,EAAY,MAAMhO,IAAI,CAACqO,WAAL,EAAlB,CAAhB;EACD,CAJM;;ECjBP;;;;;;;AAQA;EAUA,IAAI;EACFrO,EAAAA,IAAI,CAACsO,OAAL,CAAaC,CAAb,GAAiBvO,IAAI,CAACsO,OAAL,CAAaC,CAAb,IAAkB,EAAnC;EACD,CAFD,CAEE,OAAOC,KAAP,EAAc,EAAd;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.core=function(e){"use strict";try{self["workbox:core:4.3.1"]&&_()}catch(e){}const t=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n};class n extends Error{constructor(e,n){super(t(e,n)),this.name=e,this.details=n}}const s=new Set;const r={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:self.registration.scope},a=e=>[r.prefix,e,r.suffix].filter(e=>e.length>0).join("-"),i={updateDetails:e=>{Object.keys(r).forEach(t=>{void 0!==e[t]&&(r[t]=e[t])})},getGoogleAnalyticsName:e=>e||a(r.googleAnalytics),getPrecacheName:e=>e||a(r.precache),getPrefix:()=>r.prefix,getRuntimeName:e=>e||a(r.runtime),getSuffix:()=>r.suffix},c=e=>{const t=new URL(e,location);return t.origin===location.origin?t.pathname:t.href};async function o(){for(const e of s)await e()}const l="cacheDidUpdate",u="cacheKeyWillBeUsed",h="cacheWillUpdate",f="cachedResponseWillBeUsed",w="fetchDidFail",g="fetchDidSucceed",d="requestWillFetch",p=(e,t)=>e.filter(e=>t in e),y=async({cacheName:e,request:t,event:n,matchOptions:s,plugins:r=[]})=>{const a=await caches.open(e),i=await q({plugins:r,request:t,mode:"read"});let c=await a.match(i,s);for(const t of r)f in t&&(c=await t[f].call(t,{cacheName:e,event:n,matchOptions:s,cachedResponse:c,request:i}));return c},m=async({request:e,response:t,event:n,plugins:s})=>{let r=t,a=!1;for(let t of s)if(h in t&&(a=!0,!(r=await t[h].call(t,{request:e,response:r,event:n}))))break;return a||(r=200===r.status?r:null),r||null},q=async({request:e,mode:t,plugins:n})=>{const s=p(n,u);let r=e;for(const e of s)"string"==typeof(r=await e[u].call(e,{mode:t,request:r}))&&(r=new Request(r));return r},v={put:async({cacheName:e,request:t,response:s,event:r,plugins:a=[],matchOptions:i}={})=>{const u=await q({plugins:a,request:t,mode:"write"});if(!s)throw new n("cache-put-with-no-response",{url:c(u.url)});let h=await m({event:r,plugins:a,response:s,request:u});if(!h)return;const f=await caches.open(e),w=p(a,l);let g=w.length>0?await y({cacheName:e,matchOptions:i,request:u}):null;try{await f.put(u,h)}catch(e){throw"QuotaExceededError"===e.name&&await o(),e}for(let t of w)await t[l].call(t,{cacheName:e,event:r,oldResponse:g,newResponse:h,request:u})},match:y};class x{constructor(e,t,{onupgradeneeded:n,onversionchange:s=this.t}={}){this.s=e,this.i=t,this.o=n,this.t=s,this.l=null}get db(){return this.l}async open(){if(!this.l)return this.l=await new Promise((e,t)=>{let n=!1;setTimeout(()=>{n=!0,t(new Error("The open request was blocked and timed out"))},this.OPEN_TIMEOUT);const s=indexedDB.open(this.s,this.i);s.onerror=(()=>t(s.error)),s.onupgradeneeded=(e=>{n?(s.transaction.abort(),e.target.result.close()):this.o&&this.o(e)}),s.onsuccess=(({target:t})=>{const s=t.result;n?s.close():(s.onversionchange=this.t.bind(this),e(s))})}),this}async getKey(e,t){return(await this.getAllKeys(e,t,1))[0]}async getAll(e,t,n){return await this.getAllMatching(e,{query:t,count:n})}async getAllKeys(e,t,n){return(await this.getAllMatching(e,{query:t,count:n,includeKeys:!0})).map(({key:e})=>e)}async getAllMatching(e,{index:t,query:n=null,direction:s="next",count:r,includeKeys:a}={}){return await this.transaction([e],"readonly",(i,c)=>{const o=i.objectStore(e),l=t?o.index(t):o,u=[];l.openCursor(n,s).onsuccess=(({target:e})=>{const t=e.result;if(t){const{primaryKey:e,key:n,value:s}=t;u.push(a?{primaryKey:e,key:n,value:s}:s),r&&u.length>=r?c(u):t.continue()}else c(u)})})}async transaction(e,t,n){return await this.open(),await new Promise((s,r)=>{const a=this.l.transaction(e,t);a.onabort=(({target:e})=>r(e.error)),a.oncomplete=(()=>s()),n(a,e=>s(e))})}async u(e,t,n,...s){return await this.transaction([t],n,(n,r)=>{n.objectStore(t)[e](...s).onsuccess=(({target:e})=>{r(e.result)})})}t(){this.close()}close(){this.l&&(this.l.close(),this.l=null)}}x.prototype.OPEN_TIMEOUT=2e3;const b={readonly:["get","count","getKey","getAll","getAllKeys"],readwrite:["add","put","clear","delete"]};for(const[e,t]of Object.entries(b))for(const n of t)n in IDBObjectStore.prototype&&(x.prototype[n]=async function(t,...s){return await this.u(n,t,e,...s)});const D={fetch:async({request:e,fetchOptions:t,event:s,plugins:r=[]})=>{if(s&&s.preloadResponse){const e=await s.preloadResponse;if(e)return e}"string"==typeof e&&(e=new Request(e));const a=p(r,w),i=a.length>0?e.clone():null;try{for(let t of r)d in t&&(e=await t[d].call(t,{request:e.clone(),event:s}))}catch(e){throw new n("plugin-error-request-will-fetch",{thrownError:e})}let c=e.clone();try{let n;n="navigate"===e.mode?await fetch(e):await fetch(e,t);for(const e of r)g in e&&(n=await e[g].call(e,{event:s,request:c,response:n}));return n}catch(e){for(const t of a)await t[w].call(t,{error:e,event:s,originalRequest:i.clone(),request:c.clone()});throw e}}};var E=Object.freeze({assert:null,cacheNames:i,cacheWrapper:v,DBWrapper:x,Deferred:class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}},deleteDatabase:async e=>{await new Promise((t,n)=>{const s=indexedDB.deleteDatabase(e);s.onerror=(({target:e})=>{n(e.error)}),s.onblocked=(()=>{n(new Error("Delete blocked"))}),s.onsuccess=(()=>{t()})})},executeQuotaErrorCallbacks:o,fetchWrapper:D,getFriendlyURL:c,logger:null,WorkboxError:n});const N={get googleAnalytics(){return i.getGoogleAnalyticsName()},get precache(){return i.getPrecacheName()},get prefix(){return i.getPrefix()},get runtime(){return i.getRuntimeName()},get suffix(){return i.getSuffix()}};try{self.workbox.v=self.workbox.v||{}}catch(e){}return e._private=E,e.clientsClaim=(()=>{addEventListener("activate",()=>clients.claim())}),e.cacheNames=N,e.registerQuotaErrorCallback=function(e){s.add(e)},e.setCacheNameDetails=(e=>{i.updateDetails(e)}),e.skipWaiting=(()=>{addEventListener("install",()=>self.skipWaiting())}),e}({});
//# sourceMappingURL=workbox-core.prod.js.map
{"version":3,"file":"workbox-core.prod.js","sources":["../_version.mjs","../_private/logger.mjs","../models/messages/messageGenerator.mjs","../_private/WorkboxError.mjs","../_private/assert.mjs","../models/quotaErrorCallbacks.mjs","../_private/cacheNames.mjs","../_private/getFriendlyURL.mjs","../_private/executeQuotaErrorCallbacks.mjs","../models/pluginEvents.mjs","../utils/pluginUtils.mjs","../_private/cacheWrapper.mjs","../_private/DBWrapper.mjs","../_private/deleteDatabase.mjs","../_private/fetchWrapper.mjs","../_private/Deferred.mjs","../cacheNames.mjs","../index.mjs","../clientsClaim.mjs","../registerQuotaErrorCallback.mjs","../setCacheNameDetails.mjs","../skipWaiting.mjs"],"sourcesContent":["try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst logger = process.env.NODE_ENV === 'production' ? null : (() => {\n let inGroup = false;\n\n const methodToColorMap = {\n debug: `#7f8c8d`, // Gray\n log: `#2ecc71`, // Green\n warn: `#f39c12`, // Yellow\n error: `#c0392b`, // Red\n groupCollapsed: `#3498db`, // Blue\n groupEnd: null, // No colored prefix on groupEnd\n };\n\n const print = function(method, args) {\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n\n console[method](...logPrefix, ...args);\n\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n\n const api = {};\n for (const method of Object.keys(methodToColorMap)) {\n api[method] = (...args) => {\n print(method, args);\n };\n }\n\n return api;\n})();\n\nexport {logger};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messages} from './messages.mjs';\nimport '../../_version.mjs';\n\nconst fallback = (code, ...args) => {\n let msg = code;\n if (args.length > 0) {\n msg += ` :: ${JSON.stringify(args)}`;\n }\n return msg;\n};\n\nconst generatorFunction = (code, ...args) => {\n const message = messages[code];\n if (!message) {\n throw new Error(`Unable to find message for code '${code}'.`);\n }\n\n return message(...args);\n};\n\nexport const messageGenerator = (process.env.NODE_ENV === 'production') ?\n fallback : generatorFunction;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messageGenerator} from '../models/messages/messageGenerator.mjs';\nimport '../_version.mjs';\n\n/**\n * Workbox errors should be thrown with this class.\n * This allows use to ensure the type easily in tests,\n * helps developers identify errors from workbox\n * easily and allows use to optimise error\n * messages correctly.\n *\n * @private\n */\nclass WorkboxError extends Error {\n /**\n *\n * @param {string} errorCode The error code that\n * identifies this particular error.\n * @param {Object=} details Any relevant arguments\n * that will help developers identify issues should\n * be added as a key on the context object.\n */\n constructor(errorCode, details) {\n let message = messageGenerator(errorCode, details);\n\n super(message);\n\n this.name = errorCode;\n this.details = details;\n }\n}\n\nexport {WorkboxError};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from '../_private/WorkboxError.mjs';\nimport '../_version.mjs';\n\n/*\n * This method returns true if the current context is a service worker.\n */\nconst isSWEnv = (moduleName) => {\n if (!('ServiceWorkerGlobalScope' in self)) {\n throw new WorkboxError('not-in-sw', {moduleName});\n }\n};\n\n/*\n * This method throws if the supplied value is not an array.\n * The destructed values are required to produce a meaningful error for users.\n * The destructed and restructured object is so it's clear what is\n * needed.\n */\nconst isArray = (value, {moduleName, className, funcName, paramName}) => {\n if (!Array.isArray(value)) {\n throw new WorkboxError('not-an-array', {\n moduleName,\n className,\n funcName,\n paramName,\n });\n }\n};\n\nconst hasMethod = (object, expectedMethod,\n {moduleName, className, funcName, paramName}) => {\n const type = typeof object[expectedMethod];\n if (type !== 'function') {\n throw new WorkboxError('missing-a-method', {paramName, expectedMethod,\n moduleName, className, funcName});\n }\n};\n\nconst isType = (object, expectedType,\n {moduleName, className, funcName, paramName}) => {\n if (typeof object !== expectedType) {\n throw new WorkboxError('incorrect-type', {paramName, expectedType,\n moduleName, className, funcName});\n }\n};\n\nconst isInstance = (object, expectedClass,\n {moduleName, className, funcName,\n paramName, isReturnValueProblem}) => {\n if (!(object instanceof expectedClass)) {\n throw new WorkboxError('incorrect-class', {paramName, expectedClass,\n moduleName, className, funcName, isReturnValueProblem});\n }\n};\n\nconst isOneOf = (value, validValues, {paramName}) => {\n if (!validValues.includes(value)) {\n throw new WorkboxError('invalid-value', {\n paramName,\n value,\n validValueDescription: `Valid values are ${JSON.stringify(validValues)}.`,\n });\n }\n};\n\nconst isArrayOfClass = (value, expectedClass,\n {moduleName, className, funcName, paramName}) => {\n const error = new WorkboxError('not-array-of-class', {\n value, expectedClass,\n moduleName, className, funcName, paramName,\n });\n if (!Array.isArray(value)) {\n throw error;\n }\n\n for (let item of value) {\n if (!(item instanceof expectedClass)) {\n throw error;\n }\n }\n};\n\nconst finalAssertExports = process.env.NODE_ENV === 'production' ? null : {\n hasMethod,\n isArray,\n isInstance,\n isOneOf,\n isSWEnv,\n isType,\n isArrayOfClass,\n};\n\nexport {finalAssertExports as assert};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n// Callbacks to be executed whenever there's a quota error.\nconst quotaErrorCallbacks = new Set();\n\nexport {quotaErrorCallbacks};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst _cacheNameDetails = {\n googleAnalytics: 'googleAnalytics',\n precache: 'precache-v2',\n prefix: 'workbox',\n runtime: 'runtime',\n suffix: self.registration.scope,\n};\n\nconst _createCacheName = (cacheName) => {\n return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix]\n .filter((value) => value.length > 0)\n .join('-');\n};\n\nexport const cacheNames = {\n updateDetails: (details) => {\n Object.keys(_cacheNameDetails).forEach((key) => {\n if (typeof details[key] !== 'undefined') {\n _cacheNameDetails[key] = details[key];\n }\n });\n },\n getGoogleAnalyticsName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics);\n },\n getPrecacheName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.precache);\n },\n getPrefix: () => {\n return _cacheNameDetails.prefix;\n },\n getRuntimeName: (userCacheName) => {\n return userCacheName || _createCacheName(_cacheNameDetails.runtime);\n },\n getSuffix: () => {\n return _cacheNameDetails.suffix;\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst getFriendlyURL = (url) => {\n const urlObj = new URL(url, location);\n if (urlObj.origin === location.origin) {\n return urlObj.pathname;\n }\n return urlObj.href;\n};\n\nexport {getFriendlyURL};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from '../_private/logger.mjs';\nimport {quotaErrorCallbacks} from '../models/quotaErrorCallbacks.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Runs all of the callback functions, one at a time sequentially, in the order\n * in which they were registered.\n *\n * @memberof workbox.core\n * @private\n */\nasync function executeQuotaErrorCallbacks() {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`About to run ${quotaErrorCallbacks.size} ` +\n `callbacks to clean up caches.`);\n }\n\n for (const callback of quotaErrorCallbacks) {\n await callback();\n if (process.env.NODE_ENV !== 'production') {\n logger.log(callback, 'is complete.');\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Finished running callbacks.');\n }\n}\n\nexport {executeQuotaErrorCallbacks};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nexport const pluginEvents = {\n CACHE_DID_UPDATE: 'cacheDidUpdate',\n CACHE_KEY_WILL_BE_USED: 'cacheKeyWillBeUsed',\n CACHE_WILL_UPDATE: 'cacheWillUpdate',\n CACHED_RESPONSE_WILL_BE_USED: 'cachedResponseWillBeUsed',\n FETCH_DID_FAIL: 'fetchDidFail',\n FETCH_DID_SUCCEED: 'fetchDidSucceed',\n REQUEST_WILL_FETCH: 'requestWillFetch',\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const pluginUtils = {\n filter: (plugins, callbackName) => {\n return plugins.filter((plugin) => callbackName in plugin);\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from './WorkboxError.mjs';\nimport {assert} from './assert.mjs';\nimport {getFriendlyURL} from './getFriendlyURL.mjs';\nimport {logger} from './logger.mjs';\nimport {executeQuotaErrorCallbacks} from './executeQuotaErrorCallbacks.mjs';\nimport {pluginEvents} from '../models/pluginEvents.mjs';\nimport {pluginUtils} from '../utils/pluginUtils.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Wrapper around cache.put().\n *\n * Will call `cacheDidUpdate` on plugins if the cache was updated, using\n * `matchOptions` when determining what the old entry is.\n *\n * @param {Object} options\n * @param {string} options.cacheName\n * @param {Request} options.request\n * @param {Response} options.response\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @param {Object} [options.matchOptions]\n *\n * @private\n * @memberof module:workbox-core\n */\nconst putWrapper = async ({\n cacheName,\n request,\n response,\n event,\n plugins = [],\n matchOptions,\n} = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n if (request.method && request.method !== 'GET') {\n throw new WorkboxError('attempt-to-cache-non-get-request', {\n url: getFriendlyURL(request.url),\n method: request.method,\n });\n }\n }\n\n const effectiveRequest = await _getEffectiveRequest({\n plugins, request, mode: 'write'});\n\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Cannot cache non-existent response for ` +\n `'${getFriendlyURL(effectiveRequest.url)}'.`);\n }\n\n throw new WorkboxError('cache-put-with-no-response', {\n url: getFriendlyURL(effectiveRequest.url),\n });\n }\n\n let responseToCache = await _isResponseSafeToCache({\n event,\n plugins,\n response,\n request: effectiveRequest,\n });\n\n if (!responseToCache) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Response '${getFriendlyURL(effectiveRequest.url)}' will ` +\n `not be cached.`, responseToCache);\n }\n return;\n }\n\n const cache = await caches.open(cacheName);\n\n const updatePlugins = pluginUtils.filter(\n plugins, pluginEvents.CACHE_DID_UPDATE);\n\n let oldResponse = updatePlugins.length > 0 ?\n await matchWrapper({cacheName, matchOptions, request: effectiveRequest}) :\n null;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Updating the '${cacheName}' cache with a new Response for ` +\n `${getFriendlyURL(effectiveRequest.url)}.`);\n }\n\n try {\n await cache.put(effectiveRequest, responseToCache);\n } catch (error) {\n // See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError\n if (error.name === 'QuotaExceededError') {\n await executeQuotaErrorCallbacks();\n }\n throw error;\n }\n\n for (let plugin of updatePlugins) {\n await plugin[pluginEvents.CACHE_DID_UPDATE].call(plugin, {\n cacheName,\n event,\n oldResponse,\n newResponse: responseToCache,\n request: effectiveRequest,\n });\n }\n};\n\n/**\n * This is a wrapper around cache.match().\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache to match against.\n * @param {Request} options.request The Request that will be used to look up\n * cache entries.\n * @param {Event} [options.event] The event that propted the action.\n * @param {Object} [options.matchOptions] Options passed to cache.match().\n * @param {Array<Object>} [options.plugins=[]] Array of plugins.\n * @return {Response} A cached response if available.\n *\n * @private\n * @memberof module:workbox-core\n */\nconst matchWrapper = async ({\n cacheName,\n request,\n event,\n matchOptions,\n plugins = [],\n}) => {\n const cache = await caches.open(cacheName);\n\n const effectiveRequest = await _getEffectiveRequest({\n plugins, request, mode: 'read'});\n\n let cachedResponse = await cache.match(effectiveRequest, matchOptions);\n if (process.env.NODE_ENV !== 'production') {\n if (cachedResponse) {\n logger.debug(`Found a cached response in '${cacheName}'.`);\n } else {\n logger.debug(`No cached response found in '${cacheName}'.`);\n }\n }\n\n for (const plugin of plugins) {\n if (pluginEvents.CACHED_RESPONSE_WILL_BE_USED in plugin) {\n cachedResponse = await plugin[pluginEvents.CACHED_RESPONSE_WILL_BE_USED]\n .call(plugin, {\n cacheName,\n event,\n matchOptions,\n cachedResponse,\n request: effectiveRequest,\n });\n if (process.env.NODE_ENV !== 'production') {\n if (cachedResponse) {\n assert.isInstance(cachedResponse, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n\n return cachedResponse;\n};\n\n/**\n * This method will call cacheWillUpdate on the available plugins (or use\n * status === 200) to determine if the Response is safe and valid to cache.\n *\n * @param {Object} options\n * @param {Request} options.request\n * @param {Response} options.response\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Response>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst _isResponseSafeToCache = async ({request, response, event, plugins}) => {\n let responseToCache = response;\n let pluginsUsed = false;\n for (let plugin of plugins) {\n if (pluginEvents.CACHE_WILL_UPDATE in plugin) {\n pluginsUsed = true;\n responseToCache = await plugin[pluginEvents.CACHE_WILL_UPDATE]\n .call(plugin, {\n request,\n response: responseToCache,\n event,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (responseToCache) {\n assert.isInstance(responseToCache, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHE_WILL_UPDATE,\n isReturnValueProblem: true,\n });\n }\n }\n\n if (!responseToCache) {\n break;\n }\n }\n }\n\n if (!pluginsUsed) {\n if (process.env.NODE_ENV !== 'production') {\n if (!responseToCache.status === 200) {\n if (responseToCache.status === 0) {\n logger.warn(`The response for '${request.url}' is an opaque ` +\n `response. The caching strategy that you're using will not ` +\n `cache opaque responses by default.`);\n } else {\n logger.debug(`The response for '${request.url}' returned ` +\n `a status code of '${response.status}' and won't be cached as a ` +\n `result.`);\n }\n }\n }\n responseToCache = responseToCache.status === 200 ? responseToCache : null;\n }\n\n return responseToCache ? responseToCache : null;\n};\n\n/**\n * Checks the list of plugins for the cacheKeyWillBeUsed callback, and\n * executes any of those callbacks found in sequence. The final `Request` object\n * returned by the last plugin is treated as the cache key for cache reads\n * and/or writes.\n *\n * @param {Object} options\n * @param {Request} options.request\n * @param {string} options.mode\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Request>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst _getEffectiveRequest = async ({request, mode, plugins}) => {\n const cacheKeyWillBeUsedPlugins = pluginUtils.filter(\n plugins, pluginEvents.CACHE_KEY_WILL_BE_USED);\n\n let effectiveRequest = request;\n for (const plugin of cacheKeyWillBeUsedPlugins) {\n effectiveRequest = await plugin[pluginEvents.CACHE_KEY_WILL_BE_USED].call(\n plugin, {mode, request: effectiveRequest});\n\n if (typeof effectiveRequest === 'string') {\n effectiveRequest = new Request(effectiveRequest);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(effectiveRequest, Request, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHE_KEY_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n\n return effectiveRequest;\n};\n\nexport const cacheWrapper = {\n put: putWrapper,\n match: matchWrapper,\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A class that wraps common IndexedDB functionality in a promise-based API.\n * It exposes all the underlying power and functionality of IndexedDB, but\n * wraps the most commonly used features in a way that's much simpler to use.\n *\n * @private\n */\nexport class DBWrapper {\n /**\n * @param {string} name\n * @param {number} version\n * @param {Object=} [callback]\n * @param {!Function} [callbacks.onupgradeneeded]\n * @param {!Function} [callbacks.onversionchange] Defaults to\n * DBWrapper.prototype._onversionchange when not specified.\n * @private\n */\n constructor(name, version, {\n onupgradeneeded,\n onversionchange = this._onversionchange,\n } = {}) {\n this._name = name;\n this._version = version;\n this._onupgradeneeded = onupgradeneeded;\n this._onversionchange = onversionchange;\n\n // If this is null, it means the database isn't open.\n this._db = null;\n }\n\n /**\n * Returns the IDBDatabase instance (not normally needed).\n *\n * @private\n */\n get db() {\n return this._db;\n }\n\n /**\n * Opens a connected to an IDBDatabase, invokes any onupgradedneeded\n * callback, and added an onversionchange callback to the database.\n *\n * @return {IDBDatabase}\n * @private\n */\n async open() {\n if (this._db) return;\n\n this._db = await new Promise((resolve, reject) => {\n // This flag is flipped to true if the timeout callback runs prior\n // to the request failing or succeeding. Note: we use a timeout instead\n // of an onblocked handler since there are cases where onblocked will\n // never never run. A timeout better handles all possible scenarios:\n // https://github.com/w3c/IndexedDB/issues/223\n let openRequestTimedOut = false;\n setTimeout(() => {\n openRequestTimedOut = true;\n reject(new Error('The open request was blocked and timed out'));\n }, this.OPEN_TIMEOUT);\n\n const openRequest = indexedDB.open(this._name, this._version);\n openRequest.onerror = () => reject(openRequest.error);\n openRequest.onupgradeneeded = (evt) => {\n if (openRequestTimedOut) {\n openRequest.transaction.abort();\n evt.target.result.close();\n } else if (this._onupgradeneeded) {\n this._onupgradeneeded(evt);\n }\n };\n openRequest.onsuccess = ({target}) => {\n const db = target.result;\n if (openRequestTimedOut) {\n db.close();\n } else {\n db.onversionchange = this._onversionchange.bind(this);\n resolve(db);\n }\n };\n });\n\n return this;\n }\n\n /**\n * Polyfills the native `getKey()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @return {Array}\n * @private\n */\n async getKey(storeName, query) {\n return (await this.getAllKeys(storeName, query, 1))[0];\n }\n\n /**\n * Polyfills the native `getAll()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @param {number} count\n * @return {Array}\n * @private\n */\n async getAll(storeName, query, count) {\n return await this.getAllMatching(storeName, {query, count});\n }\n\n\n /**\n * Polyfills the native `getAllKeys()` method. Note, this is overridden at\n * runtime if the browser supports the native method.\n *\n * @param {string} storeName\n * @param {*} query\n * @param {number} count\n * @return {Array}\n * @private\n */\n async getAllKeys(storeName, query, count) {\n return (await this.getAllMatching(\n storeName, {query, count, includeKeys: true})).map(({key}) => key);\n }\n\n /**\n * Supports flexible lookup in an object store by specifying an index,\n * query, direction, and count. This method returns an array of objects\n * with the signature .\n *\n * @param {string} storeName\n * @param {Object} [opts]\n * @param {string} [opts.index] The index to use (if specified).\n * @param {*} [opts.query]\n * @param {IDBCursorDirection} [opts.direction]\n * @param {number} [opts.count] The max number of results to return.\n * @param {boolean} [opts.includeKeys] When true, the structure of the\n * returned objects is changed from an array of values to an array of\n * objects in the form {key, primaryKey, value}.\n * @return {Array}\n * @private\n */\n async getAllMatching(storeName, {\n index,\n query = null, // IE errors if query === `undefined`.\n direction = 'next',\n count,\n includeKeys,\n } = {}) {\n return await this.transaction([storeName], 'readonly', (txn, done) => {\n const store = txn.objectStore(storeName);\n const target = index ? store.index(index) : store;\n const results = [];\n\n target.openCursor(query, direction).onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const {primaryKey, key, value} = cursor;\n results.push(includeKeys ? {primaryKey, key, value} : value);\n if (count && results.length >= count) {\n done(results);\n } else {\n cursor.continue();\n }\n } else {\n done(results);\n }\n };\n });\n }\n\n /**\n * Accepts a list of stores, a transaction type, and a callback and\n * performs a transaction. A promise is returned that resolves to whatever\n * value the callback chooses. The callback holds all the transaction logic\n * and is invoked with two arguments:\n * 1. The IDBTransaction object\n * 2. A `done` function, that's used to resolve the promise when\n * when the transaction is done, if passed a value, the promise is\n * resolved to that value.\n *\n * @param {Array<string>} storeNames An array of object store names\n * involved in the transaction.\n * @param {string} type Can be `readonly` or `readwrite`.\n * @param {!Function} callback\n * @return {*} The result of the transaction ran by the callback.\n * @private\n */\n async transaction(storeNames, type, callback) {\n await this.open();\n return await new Promise((resolve, reject) => {\n const txn = this._db.transaction(storeNames, type);\n txn.onabort = ({target}) => reject(target.error);\n txn.oncomplete = () => resolve();\n\n callback(txn, (value) => resolve(value));\n });\n }\n\n /**\n * Delegates async to a native IDBObjectStore method.\n *\n * @param {string} method The method name.\n * @param {string} storeName The object store name.\n * @param {string} type Can be `readonly` or `readwrite`.\n * @param {...*} args The list of args to pass to the native method.\n * @return {*} The result of the transaction.\n * @private\n */\n async _call(method, storeName, type, ...args) {\n const callback = (txn, done) => {\n txn.objectStore(storeName)[method](...args).onsuccess = ({target}) => {\n done(target.result);\n };\n };\n\n return await this.transaction([storeName], type, callback);\n }\n\n /**\n * The default onversionchange handler, which closes the database so other\n * connections can open without being blocked.\n *\n * @private\n */\n _onversionchange() {\n this.close();\n }\n\n /**\n * Closes the connection opened by `DBWrapper.open()`. Generally this method\n * doesn't need to be called since:\n * 1. It's usually better to keep a connection open since opening\n * a new connection is somewhat slow.\n * 2. Connections are automatically closed when the reference is\n * garbage collected.\n * The primary use case for needing to close a connection is when another\n * reference (typically in another tab) needs to upgrade it and would be\n * blocked by the current, open connection.\n *\n * @private\n */\n close() {\n if (this._db) {\n this._db.close();\n this._db = null;\n }\n }\n}\n\n// Exposed to let users modify the default timeout on a per-instance\n// or global basis.\nDBWrapper.prototype.OPEN_TIMEOUT = 2000;\n\n// Wrap native IDBObjectStore methods according to their mode.\nconst methodsToWrap = {\n 'readonly': ['get', 'count', 'getKey', 'getAll', 'getAllKeys'],\n 'readwrite': ['add', 'put', 'clear', 'delete'],\n};\nfor (const [mode, methods] of Object.entries(methodsToWrap)) {\n for (const method of methods) {\n if (method in IDBObjectStore.prototype) {\n // Don't use arrow functions here since we're outside of the class.\n DBWrapper.prototype[method] = async function(storeName, ...args) {\n return await this._call(method, storeName, mode, ...args);\n };\n }\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Deletes the database.\n * Note: this is exported separately from the DBWrapper module because most\n * usages of IndexedDB in workbox dont need deleting, and this way it can be\n * reused in tests to delete databases without creating DBWrapper instances.\n *\n * @param {string} name The database name.\n * @private\n */\nexport const deleteDatabase = async (name) => {\n await new Promise((resolve, reject) => {\n const request = indexedDB.deleteDatabase(name);\n request.onerror = ({target}) => {\n reject(target.error);\n };\n request.onblocked = () => {\n reject(new Error('Delete blocked'));\n };\n request.onsuccess = () => {\n resolve();\n };\n });\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from './WorkboxError.mjs';\nimport {logger} from './logger.mjs';\nimport {assert} from './assert.mjs';\nimport {getFriendlyURL} from '../_private/getFriendlyURL.mjs';\nimport {pluginEvents} from '../models/pluginEvents.mjs';\nimport {pluginUtils} from '../utils/pluginUtils.mjs';\nimport '../_version.mjs';\n\n/**\n * Wrapper around the fetch API.\n *\n * Will call requestWillFetch on available plugins.\n *\n * @param {Object} options\n * @param {Request|string} options.request\n * @param {Object} [options.fetchOptions]\n * @param {Event} [options.event]\n * @param {Array<Object>} [options.plugins=[]]\n * @return {Promise<Response>}\n *\n * @private\n * @memberof module:workbox-core\n */\nconst wrappedFetch = async ({\n request,\n fetchOptions,\n event,\n plugins = []}) => {\n // We *should* be able to call `await event.preloadResponse` even if it's\n // undefined, but for some reason, doing so leads to errors in our Node unit\n // tests. To work around that, explicitly check preloadResponse's value first.\n if (event && event.preloadResponse) {\n const possiblePreloadResponse = await event.preloadResponse;\n if (possiblePreloadResponse) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Using a preloaded navigation response for ` +\n `'${getFriendlyURL(request.url)}'`);\n }\n return possiblePreloadResponse;\n }\n }\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n paramName: request,\n expectedClass: 'Request',\n moduleName: 'workbox-core',\n className: 'fetchWrapper',\n funcName: 'wrappedFetch',\n });\n }\n\n const failedFetchPlugins = pluginUtils.filter(\n plugins, pluginEvents.FETCH_DID_FAIL);\n\n // If there is a fetchDidFail plugin, we need to save a clone of the\n // original request before it's either modified by a requestWillFetch\n // plugin or before the original request's body is consumed via fetch().\n const originalRequest = failedFetchPlugins.length > 0 ?\n request.clone() : null;\n\n try {\n for (let plugin of plugins) {\n if (pluginEvents.REQUEST_WILL_FETCH in plugin) {\n request = await plugin[pluginEvents.REQUEST_WILL_FETCH].call(plugin, {\n request: request.clone(),\n event,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (request) {\n assert.isInstance(request, Request, {\n moduleName: 'Plugin',\n funcName: pluginEvents.CACHED_RESPONSE_WILL_BE_USED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n } catch (err) {\n throw new WorkboxError('plugin-error-request-will-fetch', {\n thrownError: err,\n });\n }\n\n // The request can be altered by plugins with `requestWillFetch` making\n // the original request (Most likely from a `fetch` event) to be different\n // to the Request we make. Pass both to `fetchDidFail` to aid debugging.\n let pluginFilteredRequest = request.clone();\n\n try {\n let fetchResponse;\n\n // See https://github.com/GoogleChrome/workbox/issues/1796\n if (request.mode === 'navigate') {\n fetchResponse = await fetch(request);\n } else {\n fetchResponse = await fetch(request, fetchOptions);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Network request for `+\n `'${getFriendlyURL(request.url)}' returned a response with ` +\n `status '${fetchResponse.status}'.`);\n }\n\n for (const plugin of plugins) {\n if (pluginEvents.FETCH_DID_SUCCEED in plugin) {\n fetchResponse = await plugin[pluginEvents.FETCH_DID_SUCCEED]\n .call(plugin, {\n event,\n request: pluginFilteredRequest,\n response: fetchResponse,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n if (fetchResponse) {\n assert.isInstance(fetchResponse, Response, {\n moduleName: 'Plugin',\n funcName: pluginEvents.FETCH_DID_SUCCEED,\n isReturnValueProblem: true,\n });\n }\n }\n }\n }\n\n return fetchResponse;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Network request for `+\n `'${getFriendlyURL(request.url)}' threw an error.`, error);\n }\n\n for (const plugin of failedFetchPlugins) {\n await plugin[pluginEvents.FETCH_DID_FAIL].call(plugin, {\n error,\n event,\n originalRequest: originalRequest.clone(),\n request: pluginFilteredRequest.clone(),\n });\n }\n\n throw error;\n }\n};\n\nconst fetchWrapper = {\n fetch: wrappedFetch,\n};\n\nexport {fetchWrapper};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames as _cacheNames} from './_private/cacheNames.mjs';\nimport './_version.mjs';\n\n\n/**\n * Get the current cache names and prefix/suffix used by Workbox.\n *\n * `cacheNames.precache` is used for precached assets,\n * `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to\n * store `analytics.js`, and `cacheNames.runtime` is used for everything else.\n *\n * `cacheNames.prefix` can be used to retrieve just the current prefix value.\n * `cacheNames.suffix` can be used to retrieve just the current suffix value.\n *\n * @return {Object} An object with `precache`, `runtime`, `prefix`, and\n * `googleAnalytics` properties.\n *\n * @alias workbox.core.cacheNames\n */\nexport const cacheNames = {\n get googleAnalytics() {\n return _cacheNames.getGoogleAnalyticsName();\n },\n get precache() {\n return _cacheNames.getPrecacheName();\n },\n get prefix() {\n return _cacheNames.getPrefix();\n },\n get runtime() {\n return _cacheNames.getRuntimeName();\n },\n get suffix() {\n return _cacheNames.getSuffix();\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {registerQuotaErrorCallback} from './registerQuotaErrorCallback.mjs';\nimport * as _private from './_private.mjs';\nimport {clientsClaim} from './clientsClaim.mjs';\nimport {cacheNames} from './cacheNames.mjs';\nimport {setCacheNameDetails} from './setCacheNameDetails.mjs';\nimport {skipWaiting} from './skipWaiting.mjs';\nimport './_version.mjs';\n\n\n// Give our version strings something to hang off of.\ntry {\n self.workbox.v = self.workbox.v || {};\n} catch (errer) {\n // NOOP\n}\n\n/**\n * All of the Workbox service worker libraries use workbox-core for shared\n * code as well as setting default values that need to be shared (like cache\n * names).\n *\n * @namespace workbox.core\n */\n\nexport {\n _private,\n clientsClaim,\n cacheNames,\n registerQuotaErrorCallback,\n setCacheNameDetails,\n skipWaiting,\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Claim any currently available clients once the service worker\n * becomes active. This is normally used in conjunction with `skipWaiting()`.\n *\n * @alias workbox.core.clientsClaim\n */\nexport const clientsClaim = () => {\n addEventListener('activate', () => clients.claim());\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from './_private/logger.mjs';\nimport {assert} from './_private/assert.mjs';\nimport {quotaErrorCallbacks} from './models/quotaErrorCallbacks.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds a function to the set of quotaErrorCallbacks that will be executed if\n * there's a quota error.\n *\n * @param {Function} callback\n * @memberof workbox.core\n */\nfunction registerQuotaErrorCallback(callback) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(callback, 'function', {\n moduleName: 'workbox-core',\n funcName: 'register',\n paramName: 'callback',\n });\n }\n\n quotaErrorCallbacks.add(callback);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered a callback to respond to quota errors.', callback);\n }\n}\n\nexport {registerQuotaErrorCallback};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from './_private/assert.mjs';\nimport {cacheNames} from './_private/cacheNames.mjs';\nimport {WorkboxError} from './_private/WorkboxError.mjs';\nimport './_version.mjs';\n\n\n/**\n * Modifies the default cache names used by the Workbox packages.\n * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.\n *\n * @param {Object} details\n * @param {Object} [details.prefix] The string to add to the beginning of\n * the precache and runtime cache names.\n * @param {Object} [details.suffix] The string to add to the end of\n * the precache and runtime cache names.\n * @param {Object} [details.precache] The cache name to use for precache\n * caching.\n * @param {Object} [details.runtime] The cache name to use for runtime caching.\n * @param {Object} [details.googleAnalytics] The cache name to use for\n * `workbox-google-analytics` caching.\n *\n * @alias workbox.core.setCacheNameDetails\n */\nexport const setCacheNameDetails = (details) => {\n if (process.env.NODE_ENV !== 'production') {\n Object.keys(details).forEach((key) => {\n assert.isType(details[key], 'string', {\n moduleName: 'workbox-core',\n funcName: 'setCacheNameDetails',\n paramName: `details.${key}`,\n });\n });\n\n if ('precache' in details && details.precache.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'precache',\n value: details.precache,\n });\n }\n\n if ('runtime' in details && details.runtime.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'runtime',\n value: details.runtime,\n });\n }\n\n if ('googleAnalytics' in details && details.googleAnalytics.length === 0) {\n throw new WorkboxError('invalid-cache-name', {\n cacheNameId: 'googleAnalytics',\n value: details.googleAnalytics,\n });\n }\n }\n\n cacheNames.updateDetails(details);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Force a service worker to become active, instead of waiting. This is\n * normally used in conjunction with `clientsClaim()`.\n *\n * @alias workbox.core.skipWaiting\n */\nexport const skipWaiting = () => {\n // We need to explicitly call `self.skipWaiting()` here because we're\n // shadowing `skipWaiting` with this local function.\n addEventListener('install', () => self.skipWaiting());\n};\n"],"names":["self","_","e","messageGenerator","code","args","msg","length","JSON","stringify","WorkboxError","Error","constructor","errorCode","details","name","quotaErrorCallbacks","Set","_cacheNameDetails","googleAnalytics","precache","prefix","runtime","suffix","registration","scope","_createCacheName","cacheName","filter","value","join","cacheNames","updateDetails","Object","keys","forEach","key","getGoogleAnalyticsName","userCacheName","getPrecacheName","getPrefix","getRuntimeName","getSuffix","getFriendlyURL","url","urlObj","URL","location","origin","pathname","href","async","executeQuotaErrorCallbacks","callback","pluginEvents","pluginUtils","plugins","callbackName","plugin","matchWrapper","request","event","matchOptions","cache","caches","open","effectiveRequest","_getEffectiveRequest","mode","cachedResponse","match","call","_isResponseSafeToCache","response","responseToCache","pluginsUsed","status","cacheKeyWillBeUsedPlugins","Request","cacheWrapper","put","updatePlugins","oldResponse","error","newResponse","DBWrapper","version","onupgradeneeded","onversionchange","this","_onversionchange","_name","_version","_onupgradeneeded","_db","Promise","resolve","reject","openRequestTimedOut","setTimeout","OPEN_TIMEOUT","openRequest","indexedDB","onerror","evt","transaction","abort","target","result","close","onsuccess","db","bind","storeName","query","getAllKeys","count","getAllMatching","includeKeys","map","index","direction","txn","done","store","objectStore","results","openCursor","cursor","primaryKey","push","continue","storeNames","type","onabort","oncomplete","method","prototype","methodsToWrap","methods","entries","IDBObjectStore","_call","fetchWrapper","fetch","fetchOptions","preloadResponse","possiblePreloadResponse","failedFetchPlugins","originalRequest","clone","err","thrownError","pluginFilteredRequest","fetchResponse","process","promise","deleteDatabase","onblocked","_cacheNames","workbox","v","errer","addEventListener","clients","claim","add","skipWaiting"],"mappings":"yEAAA,IAAIA,KAAK,uBAAuBC,IAAI,MAAMC,ICU1C,MCkBaC,EAjBI,CAACC,KAASC,SACrBC,EAAMF,SACNC,EAAKE,OAAS,IAChBD,UAAcE,KAAKC,UAAUJ,MAExB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C,QAAU,GAAEI,OAAAA,MAClBV,EAAOU,EAAOxB,SAEhBvB,EAAQkG,UAAY,MAClB7D,EAAO,IAAItF,MAAM,qBAEnBiD,EAAQkD,UAAY,MAClBd,6EZpBS2D,4BeiBF5H,EAAa,8BAEfgI,EAAY1H,gDAGZ0H,EAAYxH,uCAGZwH,EAAYvH,kCAGZuH,EAAYtH,sCAGZsH,EAAYrH,cCvBvB,IACE1C,KAAKgK,QAAQC,EAAIjK,KAAKgK,QAAQC,GAAK,GACnC,MAAOC,uCCHmB,MAC1BC,iBAAiB,WAAY,IAAMC,QAAQC,uDCG7C,SAAoChH,GASlCrC,EAAoBsJ,IAAIjH,0BCCUvC,CAAAA,IAgClCiB,EAAWC,cAAclB,mBC9CA,MAGzBqJ,iBAAiB,UAAW,IAAMnK,KAAKuK"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.expiration = (function (exports, DBWrapper_mjs, deleteDatabase_mjs, WorkboxError_mjs, assert_mjs, logger_mjs, cacheNames_mjs, getFriendlyURL_mjs, registerQuotaErrorCallback_mjs) {
'use strict';
try {
self['workbox:expiration:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const DB_NAME = 'workbox-expiration';
const OBJECT_STORE_NAME = 'cache-entries';
const normalizeURL = unNormalizedUrl => {
const url = new URL(unNormalizedUrl, location);
url.hash = '';
return url.href;
};
/**
* Returns the timestamp model.
*
* @private
*/
class CacheTimestampsModel {
/**
*
* @param {string} cacheName
*
* @private
*/
constructor(cacheName) {
this._cacheName = cacheName;
this._db = new DBWrapper_mjs.DBWrapper(DB_NAME, 1, {
onupgradeneeded: event => this._handleUpgrade(event)
});
}
/**
* Should perform an upgrade of indexedDB.
*
* @param {Event} event
*
* @private
*/
_handleUpgrade(event) {
const db = event.target.result; // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we
// have to use the `id` keyPath here and create our own values (a
// concatenation of `url + cacheName`) instead of simply using
// `keyPath: ['url', 'cacheName']`, which is supported in other browsers.
const objStore = db.createObjectStore(OBJECT_STORE_NAME, {
keyPath: 'id'
}); // TODO(philipwalton): once we don't have to support EdgeHTML, we can
// create a single index with the keyPath `['cacheName', 'timestamp']`
// instead of doing both these indexes.
objStore.createIndex('cacheName', 'cacheName', {
unique: false
});
objStore.createIndex('timestamp', 'timestamp', {
unique: false
}); // Previous versions of `workbox-expiration` used `this._cacheName`
// as the IDBDatabase name.
deleteDatabase_mjs.deleteDatabase(this._cacheName);
}
/**
* @param {string} url
* @param {number} timestamp
*
* @private
*/
async setTimestamp(url, timestamp) {
url = normalizeURL(url);
await this._db.put(OBJECT_STORE_NAME, {
url,
timestamp,
cacheName: this._cacheName,
// Creating an ID from the URL and cache name won't be necessary once
// Edge switches to Chromium and all browsers we support work with
// array keyPaths.
id: this._getId(url)
});
}
/**
* Returns the timestamp stored for a given URL.
*
* @param {string} url
* @return {number}
*
* @private
*/
async getTimestamp(url) {
const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url));
return entry.timestamp;
}
/**
* Iterates through all the entries in the object store (from newest to
* oldest) and removes entries once either `maxCount` is reached or the
* entry's timestamp is less than `minTimestamp`.
*
* @param {number} minTimestamp
* @param {number} maxCount
*
* @private
*/
async expireEntries(minTimestamp, maxCount) {
const entriesToDelete = await this._db.transaction(OBJECT_STORE_NAME, 'readwrite', (txn, done) => {
const store = txn.objectStore(OBJECT_STORE_NAME);
const entriesToDelete = [];
let entriesNotDeletedCount = 0;
store.index('timestamp').openCursor(null, 'prev').onsuccess = ({
target
}) => {
const cursor = target.result;
if (cursor) {
const result = cursor.value; // TODO(philipwalton): once we can use a multi-key index, we
// won't have to check `cacheName` here.
if (result.cacheName === this._cacheName) {
// Delete an entry if it's older than the max age or
// if we already have the max number allowed.
if (minTimestamp && result.timestamp < minTimestamp || maxCount && entriesNotDeletedCount >= maxCount) {
// TODO(philipwalton): we should be able to delete the
// entry right here, but doing so causes an iteration
// bug in Safari stable (fixed in TP). Instead we can
// store the keys of the entries to delete, and then
// delete the separate transactions.
// https://github.com/GoogleChrome/workbox/issues/1978
// cursor.delete();
// We only need to return the URL, not the whole entry.
entriesToDelete.push(cursor.value);
} else {
entriesNotDeletedCount++;
}
}
cursor.continue();
} else {
done(entriesToDelete);
}
};
}); // TODO(philipwalton): once the Safari bug in the following issue is fixed,
// we should be able to remove this loop and do the entry deletion in the
// cursor loop above:
// https://github.com/GoogleChrome/workbox/issues/1978
const urlsDeleted = [];
for (const entry of entriesToDelete) {
await this._db.delete(OBJECT_STORE_NAME, entry.id);
urlsDeleted.push(entry.url);
}
return urlsDeleted;
}
/**
* Takes a URL and returns an ID that will be unique in the object store.
*
* @param {string} url
* @return {string}
*
* @private
*/
_getId(url) {
// Creating an ID from the URL and cache name won't be necessary once
// Edge switches to Chromium and all browsers we support work with
// array keyPaths.
return this._cacheName + '|' + normalizeURL(url);
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The `CacheExpiration` class allows you define an expiration and / or
* limit on the number of responses stored in a
* [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
*
* @memberof workbox.expiration
*/
class CacheExpiration {
/**
* To construct a new CacheExpiration instance you must provide at least
* one of the `config` properties.
*
* @param {string} cacheName Name of the cache to apply restrictions to.
* @param {Object} config
* @param {number} [config.maxEntries] The maximum number of entries to cache.
* Entries used the least will be removed as the maximum is reached.
* @param {number} [config.maxAgeSeconds] The maximum age of an entry before
* it's treated as stale and removed.
*/
constructor(cacheName, config = {}) {
{
assert_mjs.assert.isType(cacheName, 'string', {
moduleName: 'workbox-expiration',
className: 'CacheExpiration',
funcName: 'constructor',
paramName: 'cacheName'
});
if (!(config.maxEntries || config.maxAgeSeconds)) {
throw new WorkboxError_mjs.WorkboxError('max-entries-or-age-required', {
moduleName: 'workbox-expiration',
className: 'CacheExpiration',
funcName: 'constructor'
});
}
if (config.maxEntries) {
assert_mjs.assert.isType(config.maxEntries, 'number', {
moduleName: 'workbox-expiration',
className: 'CacheExpiration',
funcName: 'constructor',
paramName: 'config.maxEntries'
}); // TODO: Assert is positive
}
if (config.maxAgeSeconds) {
assert_mjs.assert.isType(config.maxAgeSeconds, 'number', {
moduleName: 'workbox-expiration',
className: 'CacheExpiration',
funcName: 'constructor',
paramName: 'config.maxAgeSeconds'
}); // TODO: Assert is positive
}
}
this._isRunning = false;
this._rerunRequested = false;
this._maxEntries = config.maxEntries;
this._maxAgeSeconds = config.maxAgeSeconds;
this._cacheName = cacheName;
this._timestampModel = new CacheTimestampsModel(cacheName);
}
/**
* Expires entries for the given cache and given criteria.
*/
async expireEntries() {
if (this._isRunning) {
this._rerunRequested = true;
return;
}
this._isRunning = true;
const minTimestamp = this._maxAgeSeconds ? Date.now() - this._maxAgeSeconds * 1000 : undefined;
const urlsExpired = await this._timestampModel.expireEntries(minTimestamp, this._maxEntries); // Delete URLs from the cache
const cache = await caches.open(this._cacheName);
for (const url of urlsExpired) {
await cache.delete(url);
}
{
if (urlsExpired.length > 0) {
logger_mjs.logger.groupCollapsed(`Expired ${urlsExpired.length} ` + `${urlsExpired.length === 1 ? 'entry' : 'entries'} and removed ` + `${urlsExpired.length === 1 ? 'it' : 'them'} from the ` + `'${this._cacheName}' cache.`);
logger_mjs.logger.log(`Expired the following ${urlsExpired.length === 1 ? 'URL' : 'URLs'}:`);
urlsExpired.forEach(url => logger_mjs.logger.log(` ${url}`));
logger_mjs.logger.groupEnd();
} else {
logger_mjs.logger.debug(`Cache expiration ran and found no entries to remove.`);
}
}
this._isRunning = false;
if (this._rerunRequested) {
this._rerunRequested = false;
this.expireEntries();
}
}
/**
* Update the timestamp for the given URL. This ensures the when
* removing entries based on maximum entries, most recently used
* is accurate or when expiring, the timestamp is up-to-date.
*
* @param {string} url
*/
async updateTimestamp(url) {
{
assert_mjs.assert.isType(url, 'string', {
moduleName: 'workbox-expiration',
className: 'CacheExpiration',
funcName: 'updateTimestamp',
paramName: 'url'
});
}
await this._timestampModel.setTimestamp(url, Date.now());
}
/**
* Can be used to check if a URL has expired or not before it's used.
*
* This requires a look up from IndexedDB, so can be slow.
*
* Note: This method will not remove the cached entry, call
* `expireEntries()` to remove indexedDB and Cache entries.
*
* @param {string} url
* @return {boolean}
*/
async isURLExpired(url) {
{
if (!this._maxAgeSeconds) {
throw new WorkboxError_mjs.WorkboxError(`expired-test-without-max-age`, {
methodName: 'isURLExpired',
paramName: 'maxAgeSeconds'
});
}
}
const timestamp = await this._timestampModel.getTimestamp(url);
const expireOlderThan = Date.now() - this._maxAgeSeconds * 1000;
return timestamp < expireOlderThan;
}
/**
* Removes the IndexedDB object store used to keep track of cache expiration
* metadata.
*/
async delete() {
// Make sure we don't attempt another rerun if we're called in the middle of
// a cache expiration.
this._rerunRequested = false;
await this._timestampModel.expireEntries(Infinity); // Expires all.
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This plugin can be used in the Workbox APIs to regularly enforce a
* limit on the age and / or the number of cached requests.
*
* Whenever a cached request is used or updated, this plugin will look
* at the used Cache and remove any old or extra requests.
*
* When using `maxAgeSeconds`, requests may be used *once* after expiring
* because the expiration clean up will not have occurred until *after* the
* cached request has been used. If the request has a "Date" header, then
* a light weight expiration check is performed and the request will not be
* used immediately.
*
* When using `maxEntries`, the entry least-recently requested will be removed from the cache first.
*
* @memberof workbox.expiration
*/
class Plugin {
/**
* @param {Object} config
* @param {number} [config.maxEntries] The maximum number of entries to cache.
* Entries used the least will be removed as the maximum is reached.
* @param {number} [config.maxAgeSeconds] The maximum age of an entry before
* it's treated as stale and removed.
* @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to
* automatic deletion if the available storage quota has been exceeded.
*/
constructor(config = {}) {
{
if (!(config.maxEntries || config.maxAgeSeconds)) {
throw new WorkboxError_mjs.WorkboxError('max-entries-or-age-required', {
moduleName: 'workbox-expiration',
className: 'Plugin',
funcName: 'constructor'
});
}
if (config.maxEntries) {
assert_mjs.assert.isType(config.maxEntries, 'number', {
moduleName: 'workbox-expiration',
className: 'Plugin',
funcName: 'constructor',
paramName: 'config.maxEntries'
});
}
if (config.maxAgeSeconds) {
assert_mjs.assert.isType(config.maxAgeSeconds, 'number', {
moduleName: 'workbox-expiration',
className: 'Plugin',
funcName: 'constructor',
paramName: 'config.maxAgeSeconds'
});
}
}
this._config = config;
this._maxAgeSeconds = config.maxAgeSeconds;
this._cacheExpirations = new Map();
if (config.purgeOnQuotaError) {
registerQuotaErrorCallback_mjs.registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());
}
}
/**
* A simple helper method to return a CacheExpiration instance for a given
* cache name.
*
* @param {string} cacheName
* @return {CacheExpiration}
*
* @private
*/
_getCacheExpiration(cacheName) {
if (cacheName === cacheNames_mjs.cacheNames.getRuntimeName()) {
throw new WorkboxError_mjs.WorkboxError('expire-custom-caches-only');
}
let cacheExpiration = this._cacheExpirations.get(cacheName);
if (!cacheExpiration) {
cacheExpiration = new CacheExpiration(cacheName, this._config);
this._cacheExpirations.set(cacheName, cacheExpiration);
}
return cacheExpiration;
}
/**
* A "lifecycle" callback that will be triggered automatically by the
* `workbox.strategies` handlers when a `Response` is about to be returned
* from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to
* the handler. It allows the `Response` to be inspected for freshness and
* prevents it from being used if the `Response`'s `Date` header value is
* older than the configured `maxAgeSeconds`.
*
* @param {Object} options
* @param {string} options.cacheName Name of the cache the response is in.
* @param {Response} options.cachedResponse The `Response` object that's been
* read from a cache and whose freshness should be checked.
* @return {Response} Either the `cachedResponse`, if it's
* fresh, or `null` if the `Response` is older than `maxAgeSeconds`.
*
* @private
*/
cachedResponseWillBeUsed({
event,
request,
cacheName,
cachedResponse
}) {
if (!cachedResponse) {
return null;
}
let isFresh = this._isResponseDateFresh(cachedResponse); // Expire entries to ensure that even if the expiration date has
// expired, it'll only be used once.
const cacheExpiration = this._getCacheExpiration(cacheName);
cacheExpiration.expireEntries(); // Update the metadata for the request URL to the current timestamp,
// but don't `await` it as we don't want to block the response.
const updateTimestampDone = cacheExpiration.updateTimestamp(request.url);
if (event) {
try {
event.waitUntil(updateTimestampDone);
} catch (error) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache entry for '${getFriendlyURL_mjs.getFriendlyURL(event.request.url)}'.`);
}
}
}
return isFresh ? cachedResponse : null;
}
/**
* @param {Response} cachedResponse
* @return {boolean}
*
* @private
*/
_isResponseDateFresh(cachedResponse) {
if (!this._maxAgeSeconds) {
// We aren't expiring by age, so return true, it's fresh
return true;
} // Check if the 'date' header will suffice a quick expiration check.
// See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for
// discussion.
const dateHeaderTimestamp = this._getDateHeaderTimestamp(cachedResponse);
if (dateHeaderTimestamp === null) {
// Unable to parse date, so assume it's fresh.
return true;
} // If we have a valid headerTime, then our response is fresh iff the
// headerTime plus maxAgeSeconds is greater than the current time.
const now = Date.now();
return dateHeaderTimestamp >= now - this._maxAgeSeconds * 1000;
}
/**
* This method will extract the data header and parse it into a useful
* value.
*
* @param {Response} cachedResponse
* @return {number}
*
* @private
*/
_getDateHeaderTimestamp(cachedResponse) {
if (!cachedResponse.headers.has('date')) {
return null;
}
const dateHeader = cachedResponse.headers.get('date');
const parsedDate = new Date(dateHeader);
const headerTime = parsedDate.getTime(); // If the Date header was invalid for some reason, parsedDate.getTime()
// will return NaN.
if (isNaN(headerTime)) {
return null;
}
return headerTime;
}
/**
* A "lifecycle" callback that will be triggered automatically by the
* `workbox.strategies` handlers when an entry is added to a cache.
*
* @param {Object} options
* @param {string} options.cacheName Name of the cache that was updated.
* @param {string} options.request The Request for the cached entry.
*
* @private
*/
async cacheDidUpdate({
cacheName,
request
}) {
{
assert_mjs.assert.isType(cacheName, 'string', {
moduleName: 'workbox-expiration',
className: 'Plugin',
funcName: 'cacheDidUpdate',
paramName: 'cacheName'
});
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-expiration',
className: 'Plugin',
funcName: 'cacheDidUpdate',
paramName: 'request'
});
}
const cacheExpiration = this._getCacheExpiration(cacheName);
await cacheExpiration.updateTimestamp(request.url);
await cacheExpiration.expireEntries();
}
/**
* This is a helper method that performs two operations:
*
* - Deletes *all* the underlying Cache instances associated with this plugin
* instance, by calling caches.delete() on your behalf.
* - Deletes the metadata from IndexedDB used to keep track of expiration
* details for each Cache instance.
*
* When using cache expiration, calling this method is preferable to calling
* `caches.delete()` directly, since this will ensure that the IndexedDB
* metadata is also cleanly removed and open IndexedDB instances are deleted.
*
* Note that if you're *not* using cache expiration for a given cache, calling
* `caches.delete()` and passing in the cache's name should be sufficient.
* There is no Workbox-specific method needed for cleanup in that case.
*/
async deleteCacheAndMetadata() {
// Do this one at a time instead of all at once via `Promise.all()` to
// reduce the chance of inconsistency if a promise rejects.
for (const [cacheName, cacheExpiration] of this._cacheExpirations) {
await caches.delete(cacheName);
await cacheExpiration.delete();
} // Reset this._cacheExpirations to its initial state.
this._cacheExpirations = new Map();
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.CacheExpiration = CacheExpiration;
exports.Plugin = Plugin;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core));
//# sourceMappingURL=workbox-expiration.dev.js.map
{"version":3,"file":"workbox-expiration.dev.js","sources":["../_version.mjs","../models/CacheTimestampsModel.mjs","../CacheExpiration.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:expiration:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport {deleteDatabase} from 'workbox-core/_private/deleteDatabase.mjs';\nimport '../_version.mjs';\n\n\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\n\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location);\n url.hash = '';\n\n return url.href;\n};\n\n\n/**\n * Returns the timestamp model.\n *\n * @private\n */\nclass CacheTimestampsModel {\n /**\n *\n * @param {string} cacheName\n *\n * @private\n */\n constructor(cacheName) {\n this._cacheName = cacheName;\n\n this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\n });\n }\n\n /**\n * Should perform an upgrade of indexedDB.\n *\n * @param {Event} event\n *\n * @private\n */\n _handleUpgrade(event) {\n const db = event.target.result;\n\n // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we\n // have to use the `id` keyPath here and create our own values (a\n // concatenation of `url + cacheName`) instead of simply using\n // `keyPath: ['url', 'cacheName']`, which is supported in other browsers.\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {keyPath: 'id'});\n\n // TODO(philipwalton): once we don't have to support EdgeHTML, we can\n // create a single index with the keyPath `['cacheName', 'timestamp']`\n // instead of doing both these indexes.\n objStore.createIndex('cacheName', 'cacheName', {unique: false});\n objStore.createIndex('timestamp', 'timestamp', {unique: false});\n\n // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n\n await this._db.put(OBJECT_STORE_NAME, {\n url,\n timestamp,\n cacheName: this._cacheName,\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n id: this._getId(url),\n });\n }\n\n /**\n * Returns the timestamp stored for a given URL.\n *\n * @param {string} url\n * @return {number}\n *\n * @private\n */\n async getTimestamp(url) {\n const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url));\n return entry.timestamp;\n }\n\n /**\n * Iterates through all the entries in the object store (from newest to\n * oldest) and removes entries once either `maxCount` is reached or the\n * entry's timestamp is less than `minTimestamp`.\n *\n * @param {number} minTimestamp\n * @param {number} maxCount\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(\n OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n\n store.index('timestamp')\n .openCursor(null, 'prev')\n .onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const result = cursor.value;\n // TODO(philipwalton): once we can use a multi-key index, we\n // won't have to check `cacheName` here.\n if (result.cacheName === this._cacheName) {\n // Delete an entry if it's older than the max age or\n // if we already have the max number allowed.\n if ((minTimestamp && result.timestamp < minTimestamp) ||\n (maxCount && entriesNotDeletedCount >= maxCount)) {\n // TODO(philipwalton): we should be able to delete the\n // entry right here, but doing so causes an iteration\n // bug in Safari stable (fixed in TP). Instead we can\n // store the keys of the entries to delete, and then\n // delete the separate transactions.\n // https://github.com/GoogleChrome/workbox/issues/1978\n // cursor.delete();\n\n // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n } else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n } else {\n done(entriesToDelete);\n }\n };\n });\n\n // TODO(philipwalton): once the Safari bug in the following issue is fixed,\n // we should be able to remove this loop and do the entry deletion in the\n // cursor loop above:\n // https://github.com/GoogleChrome/workbox/issues/1978\n const urlsDeleted = [];\n for (const entry of entriesToDelete) {\n await this._db.delete(OBJECT_STORE_NAME, entry.id);\n urlsDeleted.push(entry.url);\n }\n\n return urlsDeleted;\n }\n\n /**\n * Takes a URL and returns an ID that will be unique in the object store.\n *\n * @param {string} url\n * @return {string}\n *\n * @private\n */\n _getId(url) {\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n return this._cacheName + '|' + normalizeURL(url);\n }\n}\n\nexport {CacheTimestampsModel};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheTimestampsModel} from './models/CacheTimestampsModel.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport './_version.mjs';\n\n/**\n * The `CacheExpiration` class allows you define an expiration and / or\n * limit on the number of responses stored in a\n * [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).\n *\n * @memberof workbox.expiration\n */\nclass CacheExpiration {\n /**\n * To construct a new CacheExpiration instance you must provide at least\n * one of the `config` properties.\n *\n * @param {string} cacheName Name of the cache to apply restrictions to.\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n */\n constructor(cacheName, config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'cacheName',\n });\n\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n\n // TODO: Assert is positive\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds',\n });\n\n // TODO: Assert is positive\n }\n }\n\n this._isRunning = false;\n this._rerunRequested = false;\n this._maxEntries = config.maxEntries;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheName = cacheName;\n this._timestampModel = new CacheTimestampsModel(cacheName);\n }\n\n /**\n * Expires entries for the given cache and given criteria.\n */\n async expireEntries() {\n if (this._isRunning) {\n this._rerunRequested = true;\n return;\n }\n this._isRunning = true;\n\n const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : undefined;\n\n const urlsExpired = await this._timestampModel.expireEntries(\n minTimestamp, this._maxEntries);\n\n // Delete URLs from the cache\n const cache = await caches.open(this._cacheName);\n for (const url of urlsExpired) {\n await cache.delete(url);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(\n `Expired ${urlsExpired.length} ` +\n `${urlsExpired.length === 1 ? 'entry' : 'entries'} and removed ` +\n `${urlsExpired.length === 1 ? 'it' : 'them'} from the ` +\n `'${this._cacheName}' cache.`);\n logger.log(`Expired the following ${urlsExpired.length === 1 ?\n 'URL' : 'URLs'}:`);\n urlsExpired.forEach((url) => logger.log(` ${url}`));\n logger.groupEnd();\n } else {\n logger.debug(`Cache expiration ran and found no entries to remove.`);\n }\n }\n\n this._isRunning = false;\n if (this._rerunRequested) {\n this._rerunRequested = false;\n this.expireEntries();\n }\n }\n\n /**\n * Update the timestamp for the given URL. This ensures the when\n * removing entries based on maximum entries, most recently used\n * is accurate or when expiring, the timestamp is up-to-date.\n *\n * @param {string} url\n */\n async updateTimestamp(url) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(url, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'updateTimestamp',\n paramName: 'url',\n });\n }\n\n await this._timestampModel.setTimestamp(url, Date.now());\n }\n\n /**\n * Can be used to check if a URL has expired or not before it's used.\n *\n * This requires a look up from IndexedDB, so can be slow.\n *\n * Note: This method will not remove the cached entry, call\n * `expireEntries()` to remove indexedDB and Cache entries.\n *\n * @param {string} url\n * @return {boolean}\n */\n async isURLExpired(url) {\n if (process.env.NODE_ENV !== 'production') {\n if (!this._maxAgeSeconds) {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n }\n\n const timestamp = await this._timestampModel.getTimestamp(url);\n const expireOlderThan = Date.now() - (this._maxAgeSeconds * 1000);\n return (timestamp < expireOlderThan);\n }\n\n /**\n * Removes the IndexedDB object store used to keep track of cache expiration\n * metadata.\n */\n async delete() {\n // Make sure we don't attempt another rerun if we're called in the middle of\n // a cache expiration.\n this._rerunRequested = false;\n await this._timestampModel.expireEntries(Infinity); // Expires all.\n }\n}\n\nexport {CacheExpiration};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {registerQuotaErrorCallback}\n from 'workbox-core/registerQuotaErrorCallback.mjs';\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport './_version.mjs';\n\n/**\n * This plugin can be used in the Workbox APIs to regularly enforce a\n * limit on the age and / or the number of cached requests.\n *\n * Whenever a cached request is used or updated, this plugin will look\n * at the used Cache and remove any old or extra requests.\n *\n * When using `maxAgeSeconds`, requests may be used *once* after expiring\n * because the expiration clean up will not have occurred until *after* the\n * cached request has been used. If the request has a \"Date\" header, then\n * a light weight expiration check is performed and the request will not be\n * used immediately.\n *\n * When using `maxEntries`, the entry least-recently requested will be removed from the cache first.\n *\n * @memberof workbox.expiration\n */\nclass Plugin {\n /**\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n * @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to\n * automatic deletion if the available storage quota has been exceeded.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds',\n });\n }\n }\n\n this._config = config;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheExpirations = new Map();\n\n if (config.purgeOnQuotaError) {\n registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());\n }\n }\n\n /**\n * A simple helper method to return a CacheExpiration instance for a given\n * cache name.\n *\n * @param {string} cacheName\n * @return {CacheExpiration}\n *\n * @private\n */\n _getCacheExpiration(cacheName) {\n if (cacheName === cacheNames.getRuntimeName()) {\n throw new WorkboxError('expire-custom-caches-only');\n }\n\n let cacheExpiration = this._cacheExpirations.get(cacheName);\n if (!cacheExpiration) {\n cacheExpiration = new CacheExpiration(cacheName, this._config);\n this._cacheExpirations.set(cacheName, cacheExpiration);\n }\n return cacheExpiration;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.strategies` handlers when a `Response` is about to be returned\n * from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to\n * the handler. It allows the `Response` to be inspected for freshness and\n * prevents it from being used if the `Response`'s `Date` header value is\n * older than the configured `maxAgeSeconds`.\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache the response is in.\n * @param {Response} options.cachedResponse The `Response` object that's been\n * read from a cache and whose freshness should be checked.\n * @return {Response} Either the `cachedResponse`, if it's\n * fresh, or `null` if the `Response` is older than `maxAgeSeconds`.\n *\n * @private\n */\n cachedResponseWillBeUsed({event, request, cacheName, cachedResponse}) {\n if (!cachedResponse) {\n return null;\n }\n\n let isFresh = this._isResponseDateFresh(cachedResponse);\n\n // Expire entries to ensure that even if the expiration date has\n // expired, it'll only be used once.\n const cacheExpiration = this._getCacheExpiration(cacheName);\n cacheExpiration.expireEntries();\n\n // Update the metadata for the request URL to the current timestamp,\n // but don't `await` it as we don't want to block the response.\n const updateTimestampDone = cacheExpiration.updateTimestamp(request.url);\n if (event) {\n try {\n event.waitUntil(updateTimestampDone);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for '${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n\n return isFresh ? cachedResponse : null;\n }\n\n /**\n * @param {Response} cachedResponse\n * @return {boolean}\n *\n * @private\n */\n _isResponseDateFresh(cachedResponse) {\n if (!this._maxAgeSeconds) {\n // We aren't expiring by age, so return true, it's fresh\n return true;\n }\n\n // Check if the 'date' header will suffice a quick expiration check.\n // See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for\n // discussion.\n const dateHeaderTimestamp = this._getDateHeaderTimestamp(cachedResponse);\n if (dateHeaderTimestamp === null) {\n // Unable to parse date, so assume it's fresh.\n return true;\n }\n\n // If we have a valid headerTime, then our response is fresh iff the\n // headerTime plus maxAgeSeconds is greater than the current time.\n const now = Date.now();\n return dateHeaderTimestamp >= now - (this._maxAgeSeconds * 1000);\n }\n\n /**\n * This method will extract the data header and parse it into a useful\n * value.\n *\n * @param {Response} cachedResponse\n * @return {number}\n *\n * @private\n */\n _getDateHeaderTimestamp(cachedResponse) {\n if (!cachedResponse.headers.has('date')) {\n return null;\n }\n\n const dateHeader = cachedResponse.headers.get('date');\n const parsedDate = new Date(dateHeader);\n const headerTime = parsedDate.getTime();\n\n // If the Date header was invalid for some reason, parsedDate.getTime()\n // will return NaN.\n if (isNaN(headerTime)) {\n return null;\n }\n\n return headerTime;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.strategies` handlers when an entry is added to a cache.\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache that was updated.\n * @param {string} options.request The Request for the cached entry.\n *\n * @private\n */\n async cacheDidUpdate({cacheName, request}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await cacheExpiration.expireEntries();\n }\n\n\n /**\n * This is a helper method that performs two operations:\n *\n * - Deletes *all* the underlying Cache instances associated with this plugin\n * instance, by calling caches.delete() on your behalf.\n * - Deletes the metadata from IndexedDB used to keep track of expiration\n * details for each Cache instance.\n *\n * When using cache expiration, calling this method is preferable to calling\n * `caches.delete()` directly, since this will ensure that the IndexedDB\n * metadata is also cleanly removed and open IndexedDB instances are deleted.\n *\n * Note that if you're *not* using cache expiration for a given cache, calling\n * `caches.delete()` and passing in the cache's name should be sufficient.\n * There is no Workbox-specific method needed for cleanup in that case.\n */\n async deleteCacheAndMetadata() {\n // Do this one at a time instead of all at once via `Promise.all()` to\n // reduce the chance of inconsistency if a promise rejects.\n for (const [cacheName, cacheExpiration] of this._cacheExpirations) {\n await caches.delete(cacheName);\n await cacheExpiration.delete();\n }\n\n // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.expiration\n */\n\nexport {\n CacheExpiration,\n Plugin,\n};\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","hash","href","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","_handleUpgrade","db","target","result","objStore","createObjectStore","keyPath","createIndex","unique","deleteDatabase","setTimestamp","timestamp","put","id","_getId","getTimestamp","entry","get","expireEntries","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","store","objectStore","entriesNotDeletedCount","index","openCursor","onsuccess","cursor","value","push","continue","urlsDeleted","delete","CacheExpiration","config","assert","isType","moduleName","className","funcName","paramName","maxEntries","maxAgeSeconds","WorkboxError","_isRunning","_rerunRequested","_maxEntries","_maxAgeSeconds","_timestampModel","Date","now","undefined","urlsExpired","cache","caches","open","length","logger","groupCollapsed","log","forEach","groupEnd","debug","updateTimestamp","isURLExpired","methodName","expireOlderThan","Infinity","Plugin","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","_getCacheExpiration","cacheNames","getRuntimeName","cacheExpiration","set","cachedResponseWillBeUsed","request","cachedResponse","isFresh","_isResponseDateFresh","updateTimestampDone","waitUntil","error","warn","getFriendlyURL","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","parsedDate","headerTime","getTime","isNaN","cacheDidUpdate","isInstance","Request"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,0BAAD,CAAJ,IAAkCC,CAAC,EAAnC;EAAsC,CAA1C,CAA0C,OAAMC,CAAN,EAAQ;;ECAlD;;;;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C,eAAe,GAAG,KAAKH,mBAAL,CAAyBrF,SAAzB,CAAxB;;EACA,UAAMwF,eAAe,CAACf,eAAhB,CAAgCkB,OAAO,CAAClG,GAAxC,CAAN;EACA,UAAM+F,eAAe,CAAChE,aAAhB,EAAN;EACD;EAGD;;;;;;;;;;;;;;;;;;EAgBA,QAAM4D,sBAAN,GAA+B;EAC7B;EACA;EACA,SAAK,MAAM,CAACpF,SAAD,EAAYwF,eAAZ,CAAX,IAA2C,KAAKR,iBAAhD,EAAmE;EACjE,YAAMhB,MAAM,CAACtB,MAAP,CAAc1C,SAAd,CAAN;EACA,YAAMwF,eAAe,CAAC9C,MAAhB,EAAN;EACD,KAN4B;;;EAS7B,SAAKsC,iBAAL,GAAyB,IAAIC,GAAJ,EAAzB;EACD;;EApOU;;ECpCb;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.expiration=function(t,e,s,i,a,n){"use strict";try{self["workbox:expiration:4.3.1"]&&_()}catch(t){}const h="workbox-expiration",c="cache-entries",r=t=>{const e=new URL(t,location);return e.hash="",e.href};class o{constructor(t){this.t=t,this.s=new e.DBWrapper(h,1,{onupgradeneeded:t=>this.i(t)})}i(t){const e=t.target.result.createObjectStore(c,{keyPath:"id"});e.createIndex("cacheName","cacheName",{unique:!1}),e.createIndex("timestamp","timestamp",{unique:!1}),s.deleteDatabase(this.t)}async setTimestamp(t,e){t=r(t),await this.s.put(c,{url:t,timestamp:e,cacheName:this.t,id:this.h(t)})}async getTimestamp(t){return(await this.s.get(c,this.h(t))).timestamp}async expireEntries(t,e){const s=await this.s.transaction(c,"readwrite",(s,i)=>{const a=s.objectStore(c),n=[];let h=0;a.index("timestamp").openCursor(null,"prev").onsuccess=(({target:s})=>{const a=s.result;if(a){const s=a.value;s.cacheName===this.t&&(t&&s.timestamp<t||e&&h>=e?n.push(a.value):h++),a.continue()}else i(n)})}),i=[];for(const t of s)await this.s.delete(c,t.id),i.push(t.url);return i}h(t){return this.t+"|"+r(t)}}class u{constructor(t,e={}){this.o=!1,this.u=!1,this.l=e.maxEntries,this.p=e.maxAgeSeconds,this.t=t,this.m=new o(t)}async expireEntries(){if(this.o)return void(this.u=!0);this.o=!0;const t=this.p?Date.now()-1e3*this.p:void 0,e=await this.m.expireEntries(t,this.l),s=await caches.open(this.t);for(const t of e)await s.delete(t);this.o=!1,this.u&&(this.u=!1,this.expireEntries())}async updateTimestamp(t){await this.m.setTimestamp(t,Date.now())}async isURLExpired(t){return await this.m.getTimestamp(t)<Date.now()-1e3*this.p}async delete(){this.u=!1,await this.m.expireEntries(1/0)}}return t.CacheExpiration=u,t.Plugin=class{constructor(t={}){this.D=t,this.p=t.maxAgeSeconds,this.g=new Map,t.purgeOnQuotaError&&n.registerQuotaErrorCallback(()=>this.deleteCacheAndMetadata())}k(t){if(t===a.cacheNames.getRuntimeName())throw new i.WorkboxError("expire-custom-caches-only");let e=this.g.get(t);return e||(e=new u(t,this.D),this.g.set(t,e)),e}cachedResponseWillBeUsed({event:t,request:e,cacheName:s,cachedResponse:i}){if(!i)return null;let a=this.N(i);const n=this.k(s);n.expireEntries();const h=n.updateTimestamp(e.url);if(t)try{t.waitUntil(h)}catch(t){}return a?i:null}N(t){if(!this.p)return!0;const e=this._(t);return null===e||e>=Date.now()-1e3*this.p}_(t){if(!t.headers.has("date"))return null;const e=t.headers.get("date"),s=new Date(e).getTime();return isNaN(s)?null:s}async cacheDidUpdate({cacheName:t,request:e}){const s=this.k(t);await s.updateTimestamp(e.url),await s.expireEntries()}async deleteCacheAndMetadata(){for(const[t,e]of this.g)await caches.delete(t),await e.delete();this.g=new Map}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core);
//# sourceMappingURL=workbox-expiration.prod.js.map
{"version":3,"file":"workbox-expiration.prod.js","sources":["../_version.mjs","../models/CacheTimestampsModel.mjs","../CacheExpiration.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:expiration:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport {deleteDatabase} from 'workbox-core/_private/deleteDatabase.mjs';\nimport '../_version.mjs';\n\n\nconst DB_NAME = 'workbox-expiration';\nconst OBJECT_STORE_NAME = 'cache-entries';\n\nconst normalizeURL = (unNormalizedUrl) => {\n const url = new URL(unNormalizedUrl, location);\n url.hash = '';\n\n return url.href;\n};\n\n\n/**\n * Returns the timestamp model.\n *\n * @private\n */\nclass CacheTimestampsModel {\n /**\n *\n * @param {string} cacheName\n *\n * @private\n */\n constructor(cacheName) {\n this._cacheName = cacheName;\n\n this._db = new DBWrapper(DB_NAME, 1, {\n onupgradeneeded: (event) => this._handleUpgrade(event),\n });\n }\n\n /**\n * Should perform an upgrade of indexedDB.\n *\n * @param {Event} event\n *\n * @private\n */\n _handleUpgrade(event) {\n const db = event.target.result;\n\n // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we\n // have to use the `id` keyPath here and create our own values (a\n // concatenation of `url + cacheName`) instead of simply using\n // `keyPath: ['url', 'cacheName']`, which is supported in other browsers.\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {keyPath: 'id'});\n\n // TODO(philipwalton): once we don't have to support EdgeHTML, we can\n // create a single index with the keyPath `['cacheName', 'timestamp']`\n // instead of doing both these indexes.\n objStore.createIndex('cacheName', 'cacheName', {unique: false});\n objStore.createIndex('timestamp', 'timestamp', {unique: false});\n\n // Previous versions of `workbox-expiration` used `this._cacheName`\n // as the IDBDatabase name.\n deleteDatabase(this._cacheName);\n }\n\n /**\n * @param {string} url\n * @param {number} timestamp\n *\n * @private\n */\n async setTimestamp(url, timestamp) {\n url = normalizeURL(url);\n\n await this._db.put(OBJECT_STORE_NAME, {\n url,\n timestamp,\n cacheName: this._cacheName,\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n id: this._getId(url),\n });\n }\n\n /**\n * Returns the timestamp stored for a given URL.\n *\n * @param {string} url\n * @return {number}\n *\n * @private\n */\n async getTimestamp(url) {\n const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url));\n return entry.timestamp;\n }\n\n /**\n * Iterates through all the entries in the object store (from newest to\n * oldest) and removes entries once either `maxCount` is reached or the\n * entry's timestamp is less than `minTimestamp`.\n *\n * @param {number} minTimestamp\n * @param {number} maxCount\n *\n * @private\n */\n async expireEntries(minTimestamp, maxCount) {\n const entriesToDelete = await this._db.transaction(\n OBJECT_STORE_NAME, 'readwrite', (txn, done) => {\n const store = txn.objectStore(OBJECT_STORE_NAME);\n const entriesToDelete = [];\n let entriesNotDeletedCount = 0;\n\n store.index('timestamp')\n .openCursor(null, 'prev')\n .onsuccess = ({target}) => {\n const cursor = target.result;\n if (cursor) {\n const result = cursor.value;\n // TODO(philipwalton): once we can use a multi-key index, we\n // won't have to check `cacheName` here.\n if (result.cacheName === this._cacheName) {\n // Delete an entry if it's older than the max age or\n // if we already have the max number allowed.\n if ((minTimestamp && result.timestamp < minTimestamp) ||\n (maxCount && entriesNotDeletedCount >= maxCount)) {\n // TODO(philipwalton): we should be able to delete the\n // entry right here, but doing so causes an iteration\n // bug in Safari stable (fixed in TP). Instead we can\n // store the keys of the entries to delete, and then\n // delete the separate transactions.\n // https://github.com/GoogleChrome/workbox/issues/1978\n // cursor.delete();\n\n // We only need to return the URL, not the whole entry.\n entriesToDelete.push(cursor.value);\n } else {\n entriesNotDeletedCount++;\n }\n }\n cursor.continue();\n } else {\n done(entriesToDelete);\n }\n };\n });\n\n // TODO(philipwalton): once the Safari bug in the following issue is fixed,\n // we should be able to remove this loop and do the entry deletion in the\n // cursor loop above:\n // https://github.com/GoogleChrome/workbox/issues/1978\n const urlsDeleted = [];\n for (const entry of entriesToDelete) {\n await this._db.delete(OBJECT_STORE_NAME, entry.id);\n urlsDeleted.push(entry.url);\n }\n\n return urlsDeleted;\n }\n\n /**\n * Takes a URL and returns an ID that will be unique in the object store.\n *\n * @param {string} url\n * @return {string}\n *\n * @private\n */\n _getId(url) {\n // Creating an ID from the URL and cache name won't be necessary once\n // Edge switches to Chromium and all browsers we support work with\n // array keyPaths.\n return this._cacheName + '|' + normalizeURL(url);\n }\n}\n\nexport {CacheTimestampsModel};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {CacheTimestampsModel} from './models/CacheTimestampsModel.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport './_version.mjs';\n\n/**\n * The `CacheExpiration` class allows you define an expiration and / or\n * limit on the number of responses stored in a\n * [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache).\n *\n * @memberof workbox.expiration\n */\nclass CacheExpiration {\n /**\n * To construct a new CacheExpiration instance you must provide at least\n * one of the `config` properties.\n *\n * @param {string} cacheName Name of the cache to apply restrictions to.\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n */\n constructor(cacheName, config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'cacheName',\n });\n\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n\n // TODO: Assert is positive\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds',\n });\n\n // TODO: Assert is positive\n }\n }\n\n this._isRunning = false;\n this._rerunRequested = false;\n this._maxEntries = config.maxEntries;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheName = cacheName;\n this._timestampModel = new CacheTimestampsModel(cacheName);\n }\n\n /**\n * Expires entries for the given cache and given criteria.\n */\n async expireEntries() {\n if (this._isRunning) {\n this._rerunRequested = true;\n return;\n }\n this._isRunning = true;\n\n const minTimestamp = this._maxAgeSeconds ?\n Date.now() - (this._maxAgeSeconds * 1000) : undefined;\n\n const urlsExpired = await this._timestampModel.expireEntries(\n minTimestamp, this._maxEntries);\n\n // Delete URLs from the cache\n const cache = await caches.open(this._cacheName);\n for (const url of urlsExpired) {\n await cache.delete(url);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (urlsExpired.length > 0) {\n logger.groupCollapsed(\n `Expired ${urlsExpired.length} ` +\n `${urlsExpired.length === 1 ? 'entry' : 'entries'} and removed ` +\n `${urlsExpired.length === 1 ? 'it' : 'them'} from the ` +\n `'${this._cacheName}' cache.`);\n logger.log(`Expired the following ${urlsExpired.length === 1 ?\n 'URL' : 'URLs'}:`);\n urlsExpired.forEach((url) => logger.log(` ${url}`));\n logger.groupEnd();\n } else {\n logger.debug(`Cache expiration ran and found no entries to remove.`);\n }\n }\n\n this._isRunning = false;\n if (this._rerunRequested) {\n this._rerunRequested = false;\n this.expireEntries();\n }\n }\n\n /**\n * Update the timestamp for the given URL. This ensures the when\n * removing entries based on maximum entries, most recently used\n * is accurate or when expiring, the timestamp is up-to-date.\n *\n * @param {string} url\n */\n async updateTimestamp(url) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(url, 'string', {\n moduleName: 'workbox-expiration',\n className: 'CacheExpiration',\n funcName: 'updateTimestamp',\n paramName: 'url',\n });\n }\n\n await this._timestampModel.setTimestamp(url, Date.now());\n }\n\n /**\n * Can be used to check if a URL has expired or not before it's used.\n *\n * This requires a look up from IndexedDB, so can be slow.\n *\n * Note: This method will not remove the cached entry, call\n * `expireEntries()` to remove indexedDB and Cache entries.\n *\n * @param {string} url\n * @return {boolean}\n */\n async isURLExpired(url) {\n if (process.env.NODE_ENV !== 'production') {\n if (!this._maxAgeSeconds) {\n throw new WorkboxError(`expired-test-without-max-age`, {\n methodName: 'isURLExpired',\n paramName: 'maxAgeSeconds',\n });\n }\n }\n\n const timestamp = await this._timestampModel.getTimestamp(url);\n const expireOlderThan = Date.now() - (this._maxAgeSeconds * 1000);\n return (timestamp < expireOlderThan);\n }\n\n /**\n * Removes the IndexedDB object store used to keep track of cache expiration\n * metadata.\n */\n async delete() {\n // Make sure we don't attempt another rerun if we're called in the middle of\n // a cache expiration.\n this._rerunRequested = false;\n await this._timestampModel.expireEntries(Infinity); // Expires all.\n }\n}\n\nexport {CacheExpiration};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {registerQuotaErrorCallback}\n from 'workbox-core/registerQuotaErrorCallback.mjs';\n\nimport {CacheExpiration} from './CacheExpiration.mjs';\nimport './_version.mjs';\n\n/**\n * This plugin can be used in the Workbox APIs to regularly enforce a\n * limit on the age and / or the number of cached requests.\n *\n * Whenever a cached request is used or updated, this plugin will look\n * at the used Cache and remove any old or extra requests.\n *\n * When using `maxAgeSeconds`, requests may be used *once* after expiring\n * because the expiration clean up will not have occurred until *after* the\n * cached request has been used. If the request has a \"Date\" header, then\n * a light weight expiration check is performed and the request will not be\n * used immediately.\n *\n * When using `maxEntries`, the entry least-recently requested will be removed from the cache first.\n *\n * @memberof workbox.expiration\n */\nclass Plugin {\n /**\n * @param {Object} config\n * @param {number} [config.maxEntries] The maximum number of entries to cache.\n * Entries used the least will be removed as the maximum is reached.\n * @param {number} [config.maxAgeSeconds] The maximum age of an entry before\n * it's treated as stale and removed.\n * @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to\n * automatic deletion if the available storage quota has been exceeded.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.maxEntries || config.maxAgeSeconds)) {\n throw new WorkboxError('max-entries-or-age-required', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n });\n }\n\n if (config.maxEntries) {\n assert.isType(config.maxEntries, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxEntries',\n });\n }\n\n if (config.maxAgeSeconds) {\n assert.isType(config.maxAgeSeconds, 'number', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'constructor',\n paramName: 'config.maxAgeSeconds',\n });\n }\n }\n\n this._config = config;\n this._maxAgeSeconds = config.maxAgeSeconds;\n this._cacheExpirations = new Map();\n\n if (config.purgeOnQuotaError) {\n registerQuotaErrorCallback(() => this.deleteCacheAndMetadata());\n }\n }\n\n /**\n * A simple helper method to return a CacheExpiration instance for a given\n * cache name.\n *\n * @param {string} cacheName\n * @return {CacheExpiration}\n *\n * @private\n */\n _getCacheExpiration(cacheName) {\n if (cacheName === cacheNames.getRuntimeName()) {\n throw new WorkboxError('expire-custom-caches-only');\n }\n\n let cacheExpiration = this._cacheExpirations.get(cacheName);\n if (!cacheExpiration) {\n cacheExpiration = new CacheExpiration(cacheName, this._config);\n this._cacheExpirations.set(cacheName, cacheExpiration);\n }\n return cacheExpiration;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.strategies` handlers when a `Response` is about to be returned\n * from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to\n * the handler. It allows the `Response` to be inspected for freshness and\n * prevents it from being used if the `Response`'s `Date` header value is\n * older than the configured `maxAgeSeconds`.\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache the response is in.\n * @param {Response} options.cachedResponse The `Response` object that's been\n * read from a cache and whose freshness should be checked.\n * @return {Response} Either the `cachedResponse`, if it's\n * fresh, or `null` if the `Response` is older than `maxAgeSeconds`.\n *\n * @private\n */\n cachedResponseWillBeUsed({event, request, cacheName, cachedResponse}) {\n if (!cachedResponse) {\n return null;\n }\n\n let isFresh = this._isResponseDateFresh(cachedResponse);\n\n // Expire entries to ensure that even if the expiration date has\n // expired, it'll only be used once.\n const cacheExpiration = this._getCacheExpiration(cacheName);\n cacheExpiration.expireEntries();\n\n // Update the metadata for the request URL to the current timestamp,\n // but don't `await` it as we don't want to block the response.\n const updateTimestampDone = cacheExpiration.updateTimestamp(request.url);\n if (event) {\n try {\n event.waitUntil(updateTimestampDone);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache entry for '${getFriendlyURL(event.request.url)}'.`);\n }\n }\n }\n\n return isFresh ? cachedResponse : null;\n }\n\n /**\n * @param {Response} cachedResponse\n * @return {boolean}\n *\n * @private\n */\n _isResponseDateFresh(cachedResponse) {\n if (!this._maxAgeSeconds) {\n // We aren't expiring by age, so return true, it's fresh\n return true;\n }\n\n // Check if the 'date' header will suffice a quick expiration check.\n // See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for\n // discussion.\n const dateHeaderTimestamp = this._getDateHeaderTimestamp(cachedResponse);\n if (dateHeaderTimestamp === null) {\n // Unable to parse date, so assume it's fresh.\n return true;\n }\n\n // If we have a valid headerTime, then our response is fresh iff the\n // headerTime plus maxAgeSeconds is greater than the current time.\n const now = Date.now();\n return dateHeaderTimestamp >= now - (this._maxAgeSeconds * 1000);\n }\n\n /**\n * This method will extract the data header and parse it into a useful\n * value.\n *\n * @param {Response} cachedResponse\n * @return {number}\n *\n * @private\n */\n _getDateHeaderTimestamp(cachedResponse) {\n if (!cachedResponse.headers.has('date')) {\n return null;\n }\n\n const dateHeader = cachedResponse.headers.get('date');\n const parsedDate = new Date(dateHeader);\n const headerTime = parsedDate.getTime();\n\n // If the Date header was invalid for some reason, parsedDate.getTime()\n // will return NaN.\n if (isNaN(headerTime)) {\n return null;\n }\n\n return headerTime;\n }\n\n /**\n * A \"lifecycle\" callback that will be triggered automatically by the\n * `workbox.strategies` handlers when an entry is added to a cache.\n *\n * @param {Object} options\n * @param {string} options.cacheName Name of the cache that was updated.\n * @param {string} options.request The Request for the cached entry.\n *\n * @private\n */\n async cacheDidUpdate({cacheName, request}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cacheName, 'string', {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'cacheName',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-expiration',\n className: 'Plugin',\n funcName: 'cacheDidUpdate',\n paramName: 'request',\n });\n }\n\n const cacheExpiration = this._getCacheExpiration(cacheName);\n await cacheExpiration.updateTimestamp(request.url);\n await cacheExpiration.expireEntries();\n }\n\n\n /**\n * This is a helper method that performs two operations:\n *\n * - Deletes *all* the underlying Cache instances associated with this plugin\n * instance, by calling caches.delete() on your behalf.\n * - Deletes the metadata from IndexedDB used to keep track of expiration\n * details for each Cache instance.\n *\n * When using cache expiration, calling this method is preferable to calling\n * `caches.delete()` directly, since this will ensure that the IndexedDB\n * metadata is also cleanly removed and open IndexedDB instances are deleted.\n *\n * Note that if you're *not* using cache expiration for a given cache, calling\n * `caches.delete()` and passing in the cache's name should be sufficient.\n * There is no Workbox-specific method needed for cleanup in that case.\n */\n async deleteCacheAndMetadata() {\n // Do this one at a time instead of all at once via `Promise.all()` to\n // reduce the chance of inconsistency if a promise rejects.\n for (const [cacheName, cacheExpiration] of this._cacheExpirations) {\n await caches.delete(cacheName);\n await cacheExpiration.delete();\n }\n\n // Reset this._cacheExpirations to its initial state.\n this._cacheExpirations = new Map();\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","DB_NAME","OBJECT_STORE_NAME","normalizeURL","unNormalizedUrl","url","URL","location","hash","href","CacheTimestampsModel","constructor","cacheName","_cacheName","_db","DBWrapper","onupgradeneeded","event","this","_handleUpgrade","objStore","target","result","createObjectStore","keyPath","createIndex","unique","deleteDatabase","timestamp","put","id","_getId","get","minTimestamp","maxCount","entriesToDelete","transaction","txn","done","store","objectStore","entriesNotDeletedCount","index","openCursor","onsuccess","cursor","value","push","continue","urlsDeleted","entry","delete","CacheExpiration","config","_isRunning","_rerunRequested","_maxEntries","maxEntries","_maxAgeSeconds","maxAgeSeconds","_timestampModel","Date","now","undefined","urlsExpired","expireEntries","cache","caches","open","setTimestamp","getTimestamp","Infinity","_config","_cacheExpirations","Map","purgeOnQuotaError","registerQuotaErrorCallback","deleteCacheAndMetadata","_getCacheExpiration","cacheNames","getRuntimeName","WorkboxError","cacheExpiration","set","cachedResponseWillBeUsed","request","cachedResponse","isFresh","_isResponseDateFresh","updateTimestampDone","updateTimestamp","waitUntil","error","dateHeaderTimestamp","_getDateHeaderTimestamp","headers","has","dateHeader","headerTime","getTime","isNaN"],"mappings":"yFAAA,IAAIA,KAAK,6BAA6BC,IAAI,MAAMC,ICahD,MAAMC,EAAU,qBACVC,EAAoB,gBAEpBC,EAAgBC,UACdC,EAAM,IAAIC,IAAIF,EAAiBG,iBACrCF,EAAIG,KAAO,GAEJH,EAAII,MASb,MAAMC,EAOJC,YAAYC,QACLC,EAAaD,OAEbE,EAAM,IAAIC,YAAUd,EAAS,EAAG,CACnCe,gBAAkBC,GAAUC,KAAKC,EAAeF,KAWpDE,EAAeF,SAOPG,EANKH,EAAMI,OAAOC,OAMJC,kBAAkBrB,EAAmB,CAACsB,QAAS,OAKnEJ,EAASK,Y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Q/D,IAAI,QAExCkE,EADa,IAAIrC,KAAKoC,GACEE,iBAI1BC,MAAMF,GACD,KAGFA,wBAaYtF,UAACA,EAADyE,QAAYA,UAgBzBH,EAAkBhE,KAAK4D,EAAoBlE,SAC3CsE,EAAgBQ,gBAAgBL,EAAQhF,WACxC6E,EAAgBjB,mDAuBjB,MAAOrD,EAAWsE,KAAoBhE,KAAKuD,QACxCN,OAAOhB,OAAOvC,SACdsE,EAAgB/B,cAInBsB,EAAoB,IAAIC"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.navigationPreload = (function (exports, logger_mjs) {
'use strict';
try {
self['workbox:navigation-preload:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @return {boolean} Whether or not the current browser supports enabling
* navigation preload.
*
* @memberof workbox.navigationPreload
*/
function isSupported() {
return Boolean(self.registration && self.registration.navigationPreload);
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* If the browser supports Navigation Preload, then this will disable it.
*
* @memberof workbox.navigationPreload
*/
function disable() {
if (isSupported()) {
self.addEventListener('activate', event => {
event.waitUntil(self.registration.navigationPreload.disable().then(() => {
{
logger_mjs.logger.log(`Navigation preload is disabled.`);
}
}));
});
} else {
{
logger_mjs.logger.log(`Navigation preload is not supported in this browser.`);
}
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* If the browser supports Navigation Preload, then this will enable it.
*
* @param {string} [headerValue] Optionally, allows developers to
* [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
* the value of the `Service-Worker-Navigation-Preload` header which will be
* sent to the server when making the navigation request.
*
* @memberof workbox.navigationPreload
*/
function enable(headerValue) {
if (isSupported()) {
self.addEventListener('activate', event => {
event.waitUntil(self.registration.navigationPreload.enable().then(() => {
// Defaults to Service-Worker-Navigation-Preload: true if not set.
if (headerValue) {
self.registration.navigationPreload.setHeaderValue(headerValue);
}
{
logger_mjs.logger.log(`Navigation preload is enabled.`);
}
}));
});
} else {
{
logger_mjs.logger.log(`Navigation preload is not supported in this browser.`);
}
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.disable = disable;
exports.enable = enable;
exports.isSupported = isSupported;
return exports;
}({}, workbox.core._private));
//# sourceMappingURL=workbox-navigation-preload.dev.js.map
{"version":3,"file":"workbox-navigation-preload.dev.js","sources":["../_version.mjs","../isSupported.mjs","../disable.mjs","../enable.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:navigation-preload:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n/**\n * @return {boolean} Whether or not the current browser supports enabling\n * navigation preload.\n *\n * @memberof workbox.navigationPreload\n */\nfunction isSupported() {\n return Boolean(self.registration && self.registration.navigationPreload);\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will disable it.\n *\n * @memberof workbox.navigationPreload\n */\nfunction disable() {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.disable().then(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is disabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {disable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will enable it.\n *\n * @param {string} [headerValue] Optionally, allows developers to\n * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)\n * the value of the `Service-Worker-Navigation-Preload` header which will be\n * sent to the server when making the navigation request.\n *\n * @memberof workbox.navigationPreload\n */\nfunction enable(headerValue) {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.enable().then(() => {\n // Defaults to Service-Worker-Navigation-Preload: true if not set.\n if (headerValue) {\n self.registration.navigationPreload.setHeaderValue(headerValue);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is enabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {enable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {disable} from './disable.mjs';\nimport {enable} from './enable.mjs';\nimport {isSupported} from './isSupported.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.navigationPreload\n */\n\nexport {\n disable,\n enable,\n isSupported,\n};\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","disable","addEventListener","event","waitUntil","then","logger","log","enable","headerValue","setHeaderValue"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,kCAAD,CAAJ,IAA0CC,CAAC,EAA3C;EAA8C,CAAlD,CAAkD,OAAMC,CAAN,EAAQ;;ECA1D;;;;;;;AAQA,EAEA;;;;;;;E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of file
this.workbox=this.workbox||{},this.workbox.navigationPreload=function(t){"use strict";try{self["workbox:navigation-preload:4.3.1"]&&_()}catch(t){}function e(){return Boolean(self.registration&&self.registration.navigationPreload)}return t.disable=function(){e()&&self.addEventListener("activate",t=>{t.waitUntil(self.registration.navigationPreload.disable().then(()=>{}))})},t.enable=function(t){e()&&self.addEventListener("activate",e=>{e.waitUntil(self.registration.navigationPreload.enable().then(()=>{t&&self.registration.navigationPreload.setHeaderValue(t)}))})},t.isSupported=e,t}({});
//# sourceMappingURL=workbox-navigation-preload.prod.js.map
{"version":3,"file":"workbox-navigation-preload.prod.js","sources":["../_version.mjs","../isSupported.mjs","../disable.mjs","../enable.mjs"],"sourcesContent":["try{self['workbox:navigation-preload:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n/**\n * @return {boolean} Whether or not the current browser supports enabling\n * navigation preload.\n *\n * @memberof workbox.navigationPreload\n */\nfunction isSupported() {\n return Boolean(self.registration && self.registration.navigationPreload);\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will disable it.\n *\n * @memberof workbox.navigationPreload\n */\nfunction disable() {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.disable().then(() => {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is disabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {disable};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * If the browser supports Navigation Preload, then this will enable it.\n *\n * @param {string} [headerValue] Optionally, allows developers to\n * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)\n * the value of the `Service-Worker-Navigation-Preload` header which will be\n * sent to the server when making the navigation request.\n *\n * @memberof workbox.navigationPreload\n */\nfunction enable(headerValue) {\n if (isSupported()) {\n self.addEventListener('activate', (event) => {\n event.waitUntil(\n self.registration.navigationPreload.enable().then(() => {\n // Defaults to Service-Worker-Navigation-Preload: true if not set.\n if (headerValue) {\n self.registration.navigationPreload.setHeaderValue(headerValue);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is enabled.`);\n }\n })\n );\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Navigation preload is not supported in this browser.`);\n }\n }\n}\n\nexport {enable};\n"],"names":["self","_","e","isSupported","Boolean","registration","navigationPreload","addEventListener","event","waitUntil","disable","then","headerValue","enable","setHeaderValue"],"mappings":"sFAAA,IAAIA,KAAK,qCAAqCC,IAAI,MAAMC,ICgBxD,SAASC,WACAC,QAAQJ,KAAKK,cAAgBL,KAAKK,aAAaC,oCCExD,WACMH,KACFH,KAAKO,iBAAiB,WAAaC,IACjCA,EAAMC,UACFT,KAAKK,aAAaC,kBAAkBI,UAAUC,KAAK,qBCC7D,SAAgBC,GACVT,KACFH,KAAKO,iBAAiB,WAAaC,IACjCA,EAAMC,UACFT,KAAKK,aAAaC,kBAAkBO,SAASF,KAAK,KAE5CC,GACFZ,KAAKK,aAAaC,kBAAkBQ,eAAeF"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.googleAnalytics = (function (exports, Plugin_mjs, cacheNames_mjs, getFriendlyURL_mjs, logger_mjs, Route_mjs, Router_mjs, NetworkFirst_mjs, NetworkOnly_mjs) {
'use strict';
try {
self['workbox:google-analytics:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const QUEUE_NAME = 'workbox-google-analytics';
const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes
const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';
const GTM_HOST = 'www.googletagmanager.com';
const ANALYTICS_JS_PATH = '/analytics.js';
const GTAG_JS_PATH = '/gtag/js';
const GTM_JS_PATH = '/gtm.js';
// endpoints. Most of the time the default path (/collect) is used, but
// occasionally an experimental endpoint is used when testing new features,
// (e.g. /r/collect or /j/collect)
const COLLECT_PATHS_REGEX = /^\/(\w+\/)?collect/;
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Creates the requestWillDequeue callback to be used with the background
* sync queue plugin. The callback takes the failed request and adds the
* `qt` param based on the current time, as well as applies any other
* user-defined hit modifications.
*
* @param {Object} config See workbox.googleAnalytics.initialize.
* @return {Function} The requestWillDequeu callback function.
*
* @private
*/
const createOnSyncCallback = config => {
return async ({
queue
}) => {
let entry;
while (entry = await queue.shiftRequest()) {
const {
request,
timestamp
} = entry;
const url = new URL(request.url);
try {
// Measurement protocol requests can set their payload parameters in
// either the URL query string (for GET requests) or the POST body.
const params = request.method === 'POST' ? new URLSearchParams((await request.clone().text())) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
// qt param may be present and should be updated rather than replaced.
const originalHitTime = timestamp - (Number(params.get('qt')) || 0);
const queueTime = Date.now() - originalHitTime; // Set the qt param prior to applying hitFilter or parameterOverrides.
params.set('qt', queueTime); // Apply `paramterOverrideds`, if set.
if (config.parameterOverrides) {
for (const param of Object.keys(config.parameterOverrides)) {
const value = config.parameterOverrides[param];
params.set(param, value);
}
} // Apply `hitFilter`, if set.
if (typeof config.hitFilter === 'function') {
config.hitFilter.call(null, params);
} // Retry the fetch. Ignore URL search params from the URL as they're
// now in the post body.
await fetch(new Request(url.origin + url.pathname, {
body: params.toString(),
method: 'POST',
mode: 'cors',
credentials: 'omit',
headers: {
'Content-Type': 'text/plain'
}
}));
{
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(url.href)}'` + `has been replayed`);
}
} catch (err) {
await queue.unshiftRequest(entry);
{
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(url.href)}'` + `failed to replay, putting it back in the queue.`);
}
throw err;
}
}
{
logger_mjs.logger.log(`All Google Analytics request successfully replayed; ` + `the queue is now empty!`);
}
};
};
/**
* Creates GET and POST routes to catch failed Measurement Protocol hits.
*
* @param {Plugin} queuePlugin
* @return {Array<Route>} The created routes.
*
* @private
*/
const createCollectRoutes = queuePlugin => {
const match = ({
url
}) => url.hostname === GOOGLE_ANALYTICS_HOST && COLLECT_PATHS_REGEX.test(url.pathname);
const handler = new NetworkOnly_mjs.NetworkOnly({
plugins: [queuePlugin]
});
return [new Route_mjs.Route(match, handler, 'GET'), new Route_mjs.Route(match, handler, 'POST')];
};
/**
* Creates a route with a network first strategy for the analytics.js script.
*
* @param {string} cacheName
* @return {Route} The created route.
*
* @private
*/
const createAnalyticsJsRoute = cacheName => {
const match = ({
url
}) => url.hostname === GOOGLE_ANALYTICS_HOST && url.pathname === ANALYTICS_JS_PATH;
const handler = new NetworkFirst_mjs.NetworkFirst({
cacheName
});
return new Route_mjs.Route(match, handler, 'GET');
};
/**
* Creates a route with a network first strategy for the gtag.js script.
*
* @param {string} cacheName
* @return {Route} The created route.
*
* @private
*/
const createGtagJsRoute = cacheName => {
const match = ({
url
}) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH;
const handler = new NetworkFirst_mjs.NetworkFirst({
cacheName
});
return new Route_mjs.Route(match, handler, 'GET');
};
/**
* Creates a route with a network first strategy for the gtm.js script.
*
* @param {string} cacheName
* @return {Route} The created route.
*
* @private
*/
const createGtmJsRoute = cacheName => {
const match = ({
url
}) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
const handler = new NetworkFirst_mjs.NetworkFirst({
cacheName
});
return new Route_mjs.Route(match, handler, 'GET');
};
/**
* @param {Object=} [options]
* @param {Object} [options.cacheName] The cache name to store and retrieve
* analytics.js. Defaults to the cache names provided by `workbox-core`.
* @param {Object} [options.parameterOverrides]
* [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),
* expressed as key/value pairs, to be added to replayed Google Analytics
* requests. This can be used to, e.g., set a custom dimension indicating
* that the request was replayed.
* @param {Function} [options.hitFilter] A function that allows you to modify
* the hit parameters prior to replaying
* the hit. The function is invoked with the original hit's URLSearchParams
* object as its only argument.
*
* @memberof workbox.googleAnalytics
*/
const initialize = (options = {}) => {
const cacheName = cacheNames_mjs.cacheNames.getGoogleAnalyticsName(options.cacheName);
const queuePlugin = new Plugin_mjs.Plugin(QUEUE_NAME, {
maxRetentionTime: MAX_RETENTION_TIME,
onSync: createOnSyncCallback(options)
});
const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(queuePlugin)];
const router = new Router_mjs.Router();
for (const route of routes) {
router.registerRoute(route);
}
router.addFetchListener();
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.initialize = initialize;
return exports;
}({}, workbox.backgroundSync, workbox.core._private, workbox.core._private, workbox.core._private, workbox.routing, workbox.routing, workbox.strategies, workbox.strategies));
//# sourceMappingURL=workbox-offline-ga.dev.js.map
{"version":3,"file":"workbox-offline-ga.dev.js","sources":["../_version.mjs","../utils/constants.mjs","../initialize.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:google-analytics:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const QUEUE_NAME = 'workbox-google-analytics';\nexport const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes\nexport const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';\nexport const GTM_HOST = 'www.googletagmanager.com';\nexport const ANALYTICS_JS_PATH = '/analytics.js';\nexport const GTAG_JS_PATH = '/gtag/js';\nexport const GTM_JS_PATH = '/gtm.js';\nexport const COLLECT_DEFAULT_PATH = '/collect';\n\n// This RegExp matches all known Measurement Protocol single-hit collect\n// endpoints. Most of the time the default path (/collect) is used, but\n// occasionally an experimental endpoint is used when testing new features,\n// (e.g. /r/collect or /j/collect)\nexport const COLLECT_PATHS_REGEX = /^\\/(\\w+\\/)?collect/;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Plugin} from 'workbox-background-sync/Plugin.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from 'workbox-routing/Route.mjs';\nimport {Router} from 'workbox-routing/Router.mjs';\nimport {NetworkFirst} from 'workbox-strategies/NetworkFirst.mjs';\nimport {NetworkOnly} from 'workbox-strategies/NetworkOnly.mjs';\nimport {\n QUEUE_NAME,\n MAX_RETENTION_TIME,\n GOOGLE_ANALYTICS_HOST,\n GTM_HOST,\n ANALYTICS_JS_PATH,\n GTAG_JS_PATH,\n GTM_JS_PATH,\n COLLECT_PATHS_REGEX,\n} from './utils/constants.mjs';\nimport './_version.mjs';\n\n/**\n * Creates the requestWillDequeue callback to be used with the background\n * sync queue plugin. The callback takes the failed request and adds the\n * `qt` param based on the current time, as well as applies any other\n * user-defined hit modifications.\n *\n * @param {Object} config See workbox.googleAnalytics.initialize.\n * @return {Function} The requestWillDequeu callback function.\n *\n * @private\n */\nconst createOnSyncCallback = (config) => {\n return async ({queue}) => {\n let entry;\n while (entry = await queue.shiftRequest()) {\n const {request, timestamp} = entry;\n const url = new URL(request.url);\n\n try {\n // Measurement protocol requests can set their payload parameters in\n // either the URL query string (for GET requests) or the POST body.\n const params = request.method === 'POST' ?\n new URLSearchParams(await request.clone().text()) :\n url.searchParams;\n\n // Calculate the qt param, accounting for the fact that an existing\n // qt param may be present and should be updated rather than replaced.\n const originalHitTime = timestamp - (Number(params.get('qt')) || 0);\n const queueTime = Date.now() - originalHitTime;\n\n // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', queueTime);\n\n // Apply `paramterOverrideds`, if set.\n if (config.parameterOverrides) {\n for (const param of Object.keys(config.parameterOverrides)) {\n const value = config.parameterOverrides[param];\n params.set(param, value);\n }\n }\n\n // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\n }\n\n // Retry the fetch. Ignore URL search params from the URL as they're\n // now in the post body.\n await fetch(new Request(url.origin + url.pathname, {\n body: params.toString(),\n method: 'POST',\n mode: 'cors',\n credentials: 'omit',\n headers: {'Content-Type': 'text/plain'},\n }));\n\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n } catch (err) {\n await queue.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `failed to replay, putting it back in the queue.`);\n }\n throw err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All Google Analytics request successfully replayed; ` +\n `the queue is now empty!`);\n }\n };\n};\n\n/**\n * Creates GET and POST routes to catch failed Measurement Protocol hits.\n *\n * @param {Plugin} queuePlugin\n * @return {Array<Route>} The created routes.\n *\n * @private\n */\nconst createCollectRoutes = (queuePlugin) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n COLLECT_PATHS_REGEX.test(url.pathname);\n\n const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\n ];\n};\n\n/**\n * Creates a route with a network first strategy for the analytics.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createAnalyticsJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n url.pathname === ANALYTICS_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtag.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtagJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTAG_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtm.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtmJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTM_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * @param {Object=} [options]\n * @param {Object} [options.cacheName] The cache name to store and retrieve\n * analytics.js. Defaults to the cache names provided by `workbox-core`.\n * @param {Object} [options.parameterOverrides]\n * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),\n * expressed as key/value pairs, to be added to replayed Google Analytics\n * requests. This can be used to, e.g., set a custom dimension indicating\n * that the request was replayed.\n * @param {Function} [options.hitFilter] A function that allows you to modify\n * the hit parameters prior to replaying\n * the hit. The function is invoked with the original hit's URLSearchParams\n * object as its only argument.\n *\n * @memberof workbox.googleAnalytics\n */\nconst initialize = (options = {}) => {\n const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);\n\n const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n\n router.addFetchListener();\n};\n\nexport {\n initialize,\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {initialize} from './initialize.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.googleAnalytics\n */\n\nexport {\n initialize,\n};\n"],"names":["self","_","e","QUEUE_NAME","MAX_RETENTION_TIME","GOOGLE_ANALYTICS_HOST","GTM_HOST","ANALYTICS_JS_PATH","GTAG_JS_PATH","GTM_JS_PATH","COLLECT_PATHS_REGEX","createOnSyncCallback","config","queue","entry","shiftRequest","request","timestamp","url","URL","params","method","URLSearchParams","clone","text","searchParams","originalHitTime","Number","get","queueTime","Date","now","set","parameterOverrides","param","Object","keys","value","hitFilter","call","fetch","Request","origin","pathname","body","toString","mode","credentials","headers","logger","log","getFriendlyURL","href","err","unshiftRequest","createCollectRoutes","queuePlugin","match","hostname","test","handler","NetworkOnly","plugins","Route","createAnalyticsJsRoute","cacheName","NetworkFirst","createGtagJsRoute","createGtmJsRoute","initialize","options","cacheNames","getGoogleAnalyticsName","Plugin","maxRetentionTime","onSync","routes","router","Router","route","registerRoute","addFetchListener"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,gCAAD,CAAJ,IAAwCC,CAAC,EAAzC;EAA4C,CAAhD,CAAgD,OAAMC,CAAN,EAAQ;;ECAxD;;;;;;;AAQA,EAEO,MAAMC,UAAU,GAAG,0BAAnB;AACP,EAAO,MAAMC,kBAAkB,GAAG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;EAACvC,IAAAA;EAAD,GAAD,KAAWA,GAAG,CAACwC,QAAJ,KAAiBpD,QAAjB,IACrBY,GAAG,CAACyB,QAAJ,KAAiBlC,WADrB;;EAEA,QAAMmD,OAAO,GAAG,IAAIM,6BAAJ,CAAiB;EAACD,IAAAA;EAAD,GAAjB,CAAhB;EAEA,SAAO,IAAIF,eAAJ,CAAUN,KAAV,EAAiBG,OAAjB,EAA0B,KAA1B,CAAP;EACD,CAND;EAQA;;;;;;;;;;;;;;;;;;AAgBA,QAAMS,UAAU,GAAG,CAACC,OAAO,GAAG,EAAX,KAAkB;EACnC,QAAML,SAAS,GAAGM,yBAAU,CAACC,sBAAX,CAAkCF,OAAO,CAACL,SAA1C,CAAlB;EAEA,QAAMT,WAAW,GAAG,IAAIiB,iBAAJ,CAAWtE,UAAX,EAAuB;EACzCuE,IAAAA,gBAAgB,EAAEtE,kBADuB;EAEzCuE,IAAAA,MAAM,EAAEhE,oBAAoB,CAAC2D,OAAD;EAFa,GAAvB,CAApB;EAKA,QAAMM,MAAM,GAAG,CACbR,gBAAgB,CAACH,SAAD,CADH,EAEbD,sBAAsB,CAACC,SAAD,CAFT,EAGbE,iBAAiB,CAACF,SAAD,CAHJ,EAIb,GAAGV,mBAAmB,CAACC,WAAD,CAJT,CAAf;EAOA,QAAMqB,MAAM,GAAG,IAAIC,iBAAJ,EAAf;;EACA,OAAK,MAAMC,KAAX,IAAoBH,MAApB,EAA4B;EAC1BC,IAAAA,MAAM,CAACG,aAAP,CAAqBD,KAArB;EACD;;EAEDF,EAAAA,MAAM,CAACI,gBAAP;EACD,CArBD;;EChMA;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(e,t,o,n,a,c,w){"use strict";try{self["workbox:google-analytics:4.3.1"]&&_()}catch(e){}const r=/^\/(\w+\/)?collect/,s=e=>async({queue:t})=>{let o;for(;o=await t.shiftRequest();){const{request:n,timestamp:a}=o,c=new URL(n.url);try{const w="POST"===n.method?new URLSearchParams(await n.clone().text()):c.searchParams,r=a-(Number(w.get("qt"))||0),s=Date.now()-r;if(w.set("qt",s),e.parameterOverrides)for(const t of Object.keys(e.parameterOverrides)){const o=e.parameterOverrides[t];w.set(t,o)}"function"==typeof e.hitFilter&&e.hitFilter.call(null,w),await fetch(new Request(c.origin+c.pathname,{body:w.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(e){throw await t.unshiftRequest(o),e}}},i=e=>{const t=({url:e})=>"www.google-analytics.com"===e.hostname&&r.test(e.pathname),o=new w.NetworkOnly({plugins:[e]});return[new n.Route(t,o,"GET"),new n.Route(t,o,"POST")]},l=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.google-analytics.com"===e.hostname&&"/analytics.js"===e.pathname,t,"GET")},m=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtag/js"===e.pathname,t,"GET")},u=e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtm.js"===e.pathname,t,"GET")};return e.initialize=((e={})=>{const n=o.cacheNames.getGoogleAnalyticsName(e.cacheName),c=new t.Plugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:s(e)}),w=[u(n),l(n),m(n),...i(c)],r=new a.Router;for(const e of w)r.registerRoute(e);r.addFetchListener()}),e}({},workbox.backgroundSync,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies);
//# sourceMappingURL=workbox-offline-ga.prod.js.map
{"version":3,"file":"workbox-offline-ga.prod.js","sources":["../_version.mjs","../utils/constants.mjs","../initialize.mjs"],"sourcesContent":["try{self['workbox:google-analytics:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const QUEUE_NAME = 'workbox-google-analytics';\nexport const MAX_RETENTION_TIME = 60 * 48; // Two days in minutes\nexport const GOOGLE_ANALYTICS_HOST = 'www.google-analytics.com';\nexport const GTM_HOST = 'www.googletagmanager.com';\nexport const ANALYTICS_JS_PATH = '/analytics.js';\nexport const GTAG_JS_PATH = '/gtag/js';\nexport const GTM_JS_PATH = '/gtm.js';\nexport const COLLECT_DEFAULT_PATH = '/collect';\n\n// This RegExp matches all known Measurement Protocol single-hit collect\n// endpoints. Most of the time the default path (/collect) is used, but\n// occasionally an experimental endpoint is used when testing new features,\n// (e.g. /r/collect or /j/collect)\nexport const COLLECT_PATHS_REGEX = /^\\/(\\w+\\/)?collect/;\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Plugin} from 'workbox-background-sync/Plugin.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from 'workbox-routing/Route.mjs';\nimport {Router} from 'workbox-routing/Router.mjs';\nimport {NetworkFirst} from 'workbox-strategies/NetworkFirst.mjs';\nimport {NetworkOnly} from 'workbox-strategies/NetworkOnly.mjs';\nimport {\n QUEUE_NAME,\n MAX_RETENTION_TIME,\n GOOGLE_ANALYTICS_HOST,\n GTM_HOST,\n ANALYTICS_JS_PATH,\n GTAG_JS_PATH,\n GTM_JS_PATH,\n COLLECT_PATHS_REGEX,\n} from './utils/constants.mjs';\nimport './_version.mjs';\n\n/**\n * Creates the requestWillDequeue callback to be used with the background\n * sync queue plugin. The callback takes the failed request and adds the\n * `qt` param based on the current time, as well as applies any other\n * user-defined hit modifications.\n *\n * @param {Object} config See workbox.googleAnalytics.initialize.\n * @return {Function} The requestWillDequeu callback function.\n *\n * @private\n */\nconst createOnSyncCallback = (config) => {\n return async ({queue}) => {\n let entry;\n while (entry = await queue.shiftRequest()) {\n const {request, timestamp} = entry;\n const url = new URL(request.url);\n\n try {\n // Measurement protocol requests can set their payload parameters in\n // either the URL query string (for GET requests) or the POST body.\n const params = request.method === 'POST' ?\n new URLSearchParams(await request.clone().text()) :\n url.searchParams;\n\n // Calculate the qt param, accounting for the fact that an existing\n // qt param may be present and should be updated rather than replaced.\n const originalHitTime = timestamp - (Number(params.get('qt')) || 0);\n const queueTime = Date.now() - originalHitTime;\n\n // Set the qt param prior to applying hitFilter or parameterOverrides.\n params.set('qt', queueTime);\n\n // Apply `paramterOverrideds`, if set.\n if (config.parameterOverrides) {\n for (const param of Object.keys(config.parameterOverrides)) {\n const value = config.parameterOverrides[param];\n params.set(param, value);\n }\n }\n\n // Apply `hitFilter`, if set.\n if (typeof config.hitFilter === 'function') {\n config.hitFilter.call(null, params);\n }\n\n // Retry the fetch. Ignore URL search params from the URL as they're\n // now in the post body.\n await fetch(new Request(url.origin + url.pathname, {\n body: params.toString(),\n method: 'POST',\n mode: 'cors',\n credentials: 'omit',\n headers: {'Content-Type': 'text/plain'},\n }));\n\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `has been replayed`);\n }\n } catch (err) {\n await queue.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(url.href)}'` +\n `failed to replay, putting it back in the queue.`);\n }\n throw err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All Google Analytics request successfully replayed; ` +\n `the queue is now empty!`);\n }\n };\n};\n\n/**\n * Creates GET and POST routes to catch failed Measurement Protocol hits.\n *\n * @param {Plugin} queuePlugin\n * @return {Array<Route>} The created routes.\n *\n * @private\n */\nconst createCollectRoutes = (queuePlugin) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n COLLECT_PATHS_REGEX.test(url.pathname);\n\n const handler = new NetworkOnly({\n plugins: [queuePlugin],\n });\n\n return [\n new Route(match, handler, 'GET'),\n new Route(match, handler, 'POST'),\n ];\n};\n\n/**\n * Creates a route with a network first strategy for the analytics.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createAnalyticsJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GOOGLE_ANALYTICS_HOST &&\n url.pathname === ANALYTICS_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtag.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtagJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTAG_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * Creates a route with a network first strategy for the gtm.js script.\n *\n * @param {string} cacheName\n * @return {Route} The created route.\n *\n * @private\n */\nconst createGtmJsRoute = (cacheName) => {\n const match = ({url}) => url.hostname === GTM_HOST &&\n url.pathname === GTM_JS_PATH;\n const handler = new NetworkFirst({cacheName});\n\n return new Route(match, handler, 'GET');\n};\n\n/**\n * @param {Object=} [options]\n * @param {Object} [options.cacheName] The cache name to store and retrieve\n * analytics.js. Defaults to the cache names provided by `workbox-core`.\n * @param {Object} [options.parameterOverrides]\n * [Measurement Protocol parameters](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters),\n * expressed as key/value pairs, to be added to replayed Google Analytics\n * requests. This can be used to, e.g., set a custom dimension indicating\n * that the request was replayed.\n * @param {Function} [options.hitFilter] A function that allows you to modify\n * the hit parameters prior to replaying\n * the hit. The function is invoked with the original hit's URLSearchParams\n * object as its only argument.\n *\n * @memberof workbox.googleAnalytics\n */\nconst initialize = (options = {}) => {\n const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);\n\n const queuePlugin = new Plugin(QUEUE_NAME, {\n maxRetentionTime: MAX_RETENTION_TIME,\n onSync: createOnSyncCallback(options),\n });\n\n const routes = [\n createGtmJsRoute(cacheName),\n createAnalyticsJsRoute(cacheName),\n createGtagJsRoute(cacheName),\n ...createCollectRoutes(queuePlugin),\n ];\n\n const router = new Router();\n for (const route of routes) {\n router.registerRoute(route);\n }\n\n router.addFetchListener();\n};\n\nexport {\n initialize,\n};\n"],"names":["self","_","e","COLLECT_PATHS_REGEX","createOnSyncCallback","config","async","queue","entry","shiftRequest","request","timestamp","url","URL","params","method","URLSearchParams","clone","text","searchParams","originalHitTime","Number","get","queueTime","Date","now","set","parameterOverrides","param","Object","keys","value","hitFilter","call","fetch","Request","origin","pathname","body","toString","mode","credentials","headers","err","unshiftRequest","createCollectRoutes","queuePlugin","match","hostname","test","handler","NetworkOnly","plugins","Route","createAnalyticsJsRoute","cacheName","NetworkFirst","createGtagJsRoute","createGtmJsRoute","options","cacheNames","getGoogleAnalyticsName","Plugin","maxRetentionTime","onSync","routes","router","Router","route","registerRoute","addFetchListener"],"mappings":"gGAAA,IAAIA,KAAK,mCAAmCC,IAAI,MAAMC,ICU/C,MAaMC,EAAsB,qBCgB7BC,EAAwBC,GACrBC,OAAQC,MAAAA,UACTC,OACGA,QAAcD,EAAME,gBAAgB,OACnCC,QAACA,EAADC,UAAUA,GAAaH,EACvBI,EAAM,IAAIC,IAAIH,EAAQE,eAKpBE,EAA4B,SAAnBJ,EAAQK,OACnB,IAAIC,sBAAsBN,EAAQO,QAAQC,QAC1CN,EAAIO,aAIFC,EAAkBT,GAAaU,OAAOP,EAAOQ,IAAI,QAAU,GAC3DC,EAAYC,KAAKC,MAAQL,KAG/BN,EAAOY,IAAI,KAAMH,GAGblB,EAAOsB,uBACJ,MAAMC,KAASC,OAAOC,KAAKzB,EAAOsB,oBAAqB,OACpDI,EAAQ1B,EAAOsB,mBAAmBC,GACxCd,EAAOY,IAAIE,EAAOG,GAKU,mBAArB1B,EAAO2B,WAChB3B,EAAO2B,UAAUC,KAAK,KAAMnB,SAKxBoB,MAA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.workbox.precaching = (function (exports, assert_mjs, cacheNames_mjs, getFriendlyURL_mjs, logger_mjs, cacheWrapper_mjs, fetchWrapper_mjs, WorkboxError_mjs) {
'use strict';
try {
self['workbox:precaching:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const plugins = [];
const precachePlugins = {
/*
* @return {Array}
* @private
*/
get() {
return plugins;
},
/*
* @param {Array} newPlugins
* @private
*/
add(newPlugins) {
plugins.push(...newPlugins);
}
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Adds plugins to precaching.
*
* @param {Array<Object>} newPlugins
*
* @alias workbox.precaching.addPlugins
*/
const addPlugins = newPlugins => {
precachePlugins.add(newPlugins);
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @param {Response} response
* @return {Response}
*
* @private
* @memberof module:workbox-precaching
*/
async function cleanRedirect(response) {
const clonedResponse = response.clone(); // Not all browsers support the Response.body stream, so fall back
// to reading the entire body into memory as a blob.
const bodyPromise = 'body' in clonedResponse ? Promise.resolve(clonedResponse.body) : clonedResponse.blob();
const body = await bodyPromise; // new Response() is happy when passed either a stream or a Blob.
return new Response(body, {
headers: clonedResponse.headers,
status: clonedResponse.status,
statusText: clonedResponse.statusText
});
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const REVISION_SEARCH_PARAM = '__WB_REVISION__';
/**
* Converts a manifest entry into a versioned URL suitable for precaching.
*
* @param {Object} entry
* @return {string} A URL with versioning info.
*
* @private
* @memberof module:workbox-precaching
*/
function createCacheKey(entry) {
if (!entry) {
throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {
entry
});
} // If a precache manifest entry is a string, it's assumed to be a versioned
// URL, like '/app.abcd1234.js'. Return as-is.
if (typeof entry === 'string') {
const urlObject = new URL(entry, location);
return {
cacheKey: urlObject.href,
url: urlObject.href
};
}
const {
revision,
url
} = entry;
if (!url) {
throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-unexpected-type', {
entry
});
} // If there's just a URL and no revision, then it's also assumed to be a
// versioned URL.
if (!revision) {
const urlObject = new URL(url, location);
return {
cacheKey: urlObject.href,
url: urlObject.href
};
} // Otherwise, construct a properly versioned URL using the custom Workbox
// search parameter along with the revision info.
const originalURL = new URL(url, location);
const cacheKeyURL = new URL(url, location);
cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);
return {
cacheKey: cacheKeyURL.href,
url: originalURL.href
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const logGroup = (groupTitle, deletedURLs) => {
logger_mjs.logger.groupCollapsed(groupTitle);
for (const url of deletedURLs) {
logger_mjs.logger.log(url);
}
logger_mjs.logger.groupEnd();
};
/**
* @param {Array<string>} deletedURLs
*
* @private
* @memberof module:workbox-precaching
*/
function printCleanupDetails(deletedURLs) {
const deletionCount = deletedURLs.length;
if (deletionCount > 0) {
logger_mjs.logger.groupCollapsed(`During precaching cleanup, ` + `${deletionCount} cached ` + `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);
logGroup('Deleted Cache Requests', deletedURLs);
logger_mjs.logger.groupEnd();
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @param {string} groupTitle
* @param {Array<string>} urls
*
* @private
*/
function _nestedGroup(groupTitle, urls) {
if (urls.length === 0) {
return;
}
logger_mjs.logger.groupCollapsed(groupTitle);
for (const url of urls) {
logger_mjs.logger.log(url);
}
logger_mjs.logger.groupEnd();
}
/**
* @param {Array<string>} urlsToPrecache
* @param {Array<string>} urlsAlreadyPrecached
*
* @private
* @memberof module:workbox-precaching
*/
function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) {
const precachedCount = urlsToPrecache.length;
const alreadyPrecachedCount = urlsAlreadyPrecached.length;
if (precachedCount || alreadyPrecachedCount) {
let message = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;
if (alreadyPrecachedCount > 0) {
message += ` ${alreadyPrecachedCount} ` + `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;
}
logger_mjs.logger.groupCollapsed(message);
_nestedGroup(`View newly precached URLs.`, urlsToPrecache);
_nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached);
logger_mjs.logger.groupEnd();
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Performs efficient precaching of assets.
*
* @memberof module:workbox-precaching
*/
class PrecacheController {
/**
* Create a new PrecacheController.
*
* @param {string} [cacheName] An optional name for the cache, to override
* the default precache name.
*/
constructor(cacheName) {
this._cacheName = cacheNames_mjs.cacheNames.getPrecacheName(cacheName);
this._urlsToCacheKeys = new Map();
}
/**
* This method will add items to the precache list, removing duplicates
* and ensuring the information is valid.
*
* @param {
* Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>
* } entries Array of entries to precache.
*/
addToCacheList(entries) {
{
assert_mjs.assert.isArray(entries, {
moduleName: 'workbox-precaching',
className: 'PrecacheController',
funcName: 'addToCacheList',
paramName: 'entries'
});
}
for (const entry of entries) {
const {
cacheKey,
url
} = createCacheKey(entry);
if (this._urlsToCacheKeys.has(url) && this._urlsToCacheKeys.get(url) !== cacheKey) {
throw new WorkboxError_mjs.WorkboxError('add-to-cache-list-conflicting-entries', {
firstEntry: this._urlsToCacheKeys.get(url),
secondEntry: cacheKey
});
}
this._urlsToCacheKeys.set(url, cacheKey);
}
}
/**
* Precaches new and updated assets. Call this method from the service worker
* install event.
*
* @param {Object} options
* @param {Event} [options.event] The install event (if needed).
* @param {Array<Object>} [options.plugins] Plugins to be used for fetching
* and caching during install.
* @return {Promise<workbox.precaching.InstallResult>}
*/
async install({
event,
plugins
} = {}) {
{
if (plugins) {
assert_mjs.assert.isArray(plugins, {
moduleName: 'workbox-precaching',
className: 'PrecacheController',
funcName: 'install',
paramName: 'plugins'
});
}
}
const urlsToPrecache = [];
const urlsAlreadyPrecached = [];
const cache = await caches.open(this._cacheName);
const alreadyCachedRequests = await cache.keys();
const alreadyCachedURLs = new Set(alreadyCachedRequests.map(request => request.url));
for (const cacheKey of this._urlsToCacheKeys.values()) {
if (alreadyCachedURLs.has(cacheKey)) {
urlsAlreadyPrecached.push(cacheKey);
} else {
urlsToPrecache.push(cacheKey);
}
}
const precacheRequests = urlsToPrecache.map(url => {
return this._addURLToCache({
event,
plugins,
url
});
});
await Promise.all(precacheRequests);
{
printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);
}
return {
updatedURLs: urlsToPrecache,
notUpdatedURLs: urlsAlreadyPrecached
};
}
/**
* Deletes assets that are no longer present in the current precache manifest.
* Call this method from the service worker activate event.
*
* @return {Promise<workbox.precaching.CleanupResult>}
*/
async activate() {
const cache = await caches.open(this._cacheName);
const currentlyCachedRequests = await cache.keys();
const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());
const deletedURLs = [];
for (const request of currentlyCachedRequests) {
if (!expectedCacheKeys.has(request.url)) {
await cache.delete(request);
deletedURLs.push(request.url);
}
}
{
printCleanupDetails(deletedURLs);
}
return {
deletedURLs
};
}
/**
* Requests the entry and saves it to the cache if the response is valid.
* By default, any response with a status code of less than 400 (including
* opaque responses) is considered valid.
*
* If you need to use custom criteria to determine what's valid and what
* isn't, then pass in an item in `options.plugins` that implements the
* `cacheWillUpdate()` lifecycle event.
*
* @private
* @param {Object} options
* @param {string} options.url The URL to fetch and cache.
* @param {Event} [options.event] The install event (if passed).
* @param {Array<Object>} [options.plugins] An array of plugins to apply to
* fetch and caching.
*/
async _addURLToCache({
url,
event,
plugins
}) {
const request = new Request(url, {
credentials: 'same-origin'
});
let response = await fetchWrapper_mjs.fetchWrapper.fetch({
event,
plugins,
request
}); // Allow developers to override the default logic about what is and isn't
// valid by passing in a plugin implementing cacheWillUpdate(), e.g.
// a workbox.cacheableResponse.Plugin instance.
let cacheWillUpdateCallback;
for (const plugin of plugins || []) {
if ('cacheWillUpdate' in plugin) {
cacheWillUpdateCallback = plugin.cacheWillUpdate.bind(plugin);
}
}
const isValidResponse = cacheWillUpdateCallback ? // Use a callback if provided. It returns a truthy value if valid.
cacheWillUpdateCallback({
event,
request,
response
}) : // Otherwise, default to considering any response status under 400 valid.
// This includes, by default, considering opaque responses valid.
response.status < 400; // Consider this a failure, leading to the `install` handler failing, if
// we get back an invalid response.
if (!isValidResponse) {
throw new WorkboxError_mjs.WorkboxError('bad-precaching-response', {
url,
status: response.status
});
}
if (response.redirected) {
response = await cleanRedirect(response);
}
await cacheWrapper_mjs.cacheWrapper.put({
event,
plugins,
request,
response,
cacheName: this._cacheName,
matchOptions: {
ignoreSearch: true
}
});
}
/**
* Returns a mapping of a precached URL to the corresponding cache key, taking
* into account the revision information for the URL.
*
* @return {Map<string, string>} A URL to cache key mapping.
*/
getURLsToCacheKeys() {
return this._urlsToCacheKeys;
}
/**
* Returns a list of all the URLs that have been precached by the current
* service worker.
*
* @return {Array<string>} The precached URLs.
*/
getCachedURLs() {
return [...this._urlsToCacheKeys.keys()];
}
/**
* Returns the cache key used for storing a given URL. If that URL is
* unversioned, like `/index.html', then the cache key will be the original
* URL with a search parameter appended to it.
*
* @param {string} url A URL whose cache key you want to look up.
* @return {string} The versioned URL that corresponds to a cache key
* for the original URL, or undefined if that URL isn't precached.
*/
getCacheKeyForURL(url) {
const urlObject = new URL(url, location);
return this._urlsToCacheKeys.get(urlObject.href);
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
let precacheController;
/**
* @return {PrecacheController}
* @private
*/
const getOrCreatePrecacheController = () => {
if (!precacheController) {
precacheController = new PrecacheController();
}
return precacheController;
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Removes any URL search parameters that should be ignored.
*
* @param {URL} urlObject The original URL.
* @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against
* each search parameter name. Matches mean that the search parameter should be
* ignored.
* @return {URL} The URL with any ignored search parameters removed.
*
* @private
* @memberof module:workbox-precaching
*/
function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching) {
// Convert the iterable into an array at the start of the loop to make sure
// deletion doesn't mess up iteration.
for (const paramName of [...urlObject.searchParams.keys()]) {
if (ignoreURLParametersMatching.some(regExp => regExp.test(paramName))) {
urlObject.searchParams.delete(paramName);
}
}
return urlObject;
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Generator function that yields possible variations on the original URL to
* check, one at a time.
*
* @param {string} url
* @param {Object} options
*
* @private
* @memberof module:workbox-precaching
*/
function* generateURLVariations(url, {
ignoreURLParametersMatching,
directoryIndex,
cleanURLs,
urlManipulation
} = {}) {
const urlObject = new URL(url, location);
urlObject.hash = '';
yield urlObject.href;
const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);
yield urlWithoutIgnoredParams.href;
if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {
const directoryURL = new URL(urlWithoutIgnoredParams);
directoryURL.pathname += directoryIndex;
yield directoryURL.href;
}
if (cleanURLs) {
const cleanURL = new URL(urlWithoutIgnoredParams);
cleanURL.pathname += '.html';
yield cleanURL.href;
}
if (urlManipulation) {
const additionalURLs = urlManipulation({
url: urlObject
});
for (const urlToAttempt of additionalURLs) {
yield urlToAttempt.href;
}
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This function will take the request URL and manipulate it based on the
* configuration options.
*
* @param {string} url
* @param {Object} options
* @return {string} Returns the URL in the cache that matches the request,
* if possible.
*
* @private
*/
const getCacheKeyForURL = (url, options) => {
const precacheController = getOrCreatePrecacheController();
const urlsToCacheKeys = precacheController.getURLsToCacheKeys();
for (const possibleURL of generateURLVariations(url, options)) {
const possibleCacheKey = urlsToCacheKeys.get(possibleURL);
if (possibleCacheKey) {
return possibleCacheKey;
}
}
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Adds a `fetch` listener to the service worker that will
* respond to
* [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
* with precached assets.
*
* Requests for assets that aren't precached, the `FetchEvent` will not be
* responded to, allowing the event to fall through to other `fetch` event
* listeners.
*
* NOTE: when called more than once this method will replace the previously set
* configuration options. Calling it more than once is not recommended outside
* of tests.
*
* @private
* @param {Object} options
* @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
* check cache entries for a URLs ending with '/' to see if there is a hit when
* appending the `directoryIndex` value.
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
* array of regex's to remove search params when looking for a cache match.
* @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URL's that should be checked for precache matches.
*/
const addFetchListener = ({
ignoreURLParametersMatching = [/^utm_/],
directoryIndex = 'index.html',
cleanURLs = true,
urlManipulation = null
} = {}) => {
const cacheName = cacheNames_mjs.cacheNames.getPrecacheName();
addEventListener('fetch', event => {
const precachedURL = getCacheKeyForURL(event.request.url, {
cleanURLs,
directoryIndex,
ignoreURLParametersMatching,
urlManipulation
});
if (!precachedURL) {
{
logger_mjs.logger.debug(`Precaching did not find a match for ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));
}
return;
}
let responsePromise = caches.open(cacheName).then(cache => {
return cache.match(precachedURL);
}).then(cachedResponse => {
if (cachedResponse) {
return cachedResponse;
} // Fall back to the network if we don't have a cached response
// (perhaps due to manual cache cleanup).
{
logger_mjs.logger.warn(`The precached response for ` + `${getFriendlyURL_mjs.getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` + `Falling back to the network instead.`);
}
return fetch(precachedURL);
});
{
responsePromise = responsePromise.then(response => {
// Workbox is going to handle the route.
// print the routing details to the console.
logger_mjs.logger.groupCollapsed(`Precaching is responding to: ` + getFriendlyURL_mjs.getFriendlyURL(event.request.url));
logger_mjs.logger.log(`Serving the precached url: ${precachedURL}`);
logger_mjs.logger.groupCollapsed(`View request details here.`);
logger_mjs.logger.log(event.request);
logger_mjs.logger.groupEnd();
logger_mjs.logger.groupCollapsed(`View response details here.`);
logger_mjs.logger.log(response);
logger_mjs.logger.groupEnd();
logger_mjs.logger.groupEnd();
return response;
});
}
event.respondWith(responsePromise);
});
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
let listenerAdded = false;
/**
* Add a `fetch` listener to the service worker that will
* respond to
* [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}
* with precached assets.
*
* Requests for assets that aren't precached, the `FetchEvent` will not be
* responded to, allowing the event to fall through to other `fetch` event
* listeners.
*
* @param {Object} options
* @param {string} [options.directoryIndex=index.html] The `directoryIndex` will
* check cache entries for a URLs ending with '/' to see if there is a hit when
* appending the `directoryIndex` value.
* @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An
* array of regex's to remove search params when looking for a cache match.
* @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will
* check the cache for the URL with a `.html` added to the end of the end.
* @param {workbox.precaching~urlManipulation} [options.urlManipulation]
* This is a function that should take a URL and return an array of
* alternative URL's that should be checked for precache matches.
*
* @alias workbox.precaching.addRoute
*/
const addRoute = options => {
if (!listenerAdded) {
addFetchListener(options);
listenerAdded = true;
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const SUBSTRING_TO_FIND = '-precache-';
/**
* Cleans up incompatible precaches that were created by older versions of
* Workbox, by a service worker registered under the current scope.
*
* This is meant to be called as part of the `activate` event.
*
* This should be safe to use as long as you don't include `substringToFind`
* (defaulting to `-precache-`) in your non-precache cache names.
*
* @param {string} currentPrecacheName The cache name currently in use for
* precaching. This cache won't be deleted.
* @param {string} [substringToFind='-precache-'] Cache names which include this
* substring will be deleted (excluding `currentPrecacheName`).
* @return {Array<string>} A list of all the cache names that were deleted.
*
* @private
* @memberof module:workbox-precaching
*/
const deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => {
const cacheNames = await caches.keys();
const cacheNamesToDelete = cacheNames.filter(cacheName => {
return cacheName.includes(substringToFind) && cacheName.includes(self.registration.scope) && cacheName !== currentPrecacheName;
});
await Promise.all(cacheNamesToDelete.map(cacheName => caches.delete(cacheName)));
return cacheNamesToDelete;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Adds an `activate` event listener which will clean up incompatible
* precaches that were created by older versions of Workbox.
*
* @alias workbox.precaching.cleanupOutdatedCaches
*/
const cleanupOutdatedCaches = () => {
addEventListener('activate', event => {
const cacheName = cacheNames_mjs.cacheNames.getPrecacheName();
event.waitUntil(deleteOutdatedCaches(cacheName).then(cachesDeleted => {
{
if (cachesDeleted.length > 0) {
logger_mjs.logger.log(`The following out-of-date precaches were cleaned up ` + `automatically:`, cachesDeleted);
}
}
}));
});
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Takes in a URL, and returns the corresponding URL that could be used to
* lookup the entry in the precache.
*
* If a relative URL is provided, the location of the service worker file will
* be used as the base.
*
* For precached entries without revision information, the cache key will be the
* same as the original URL.
*
* For precached entries with revision information, the cache key will be the
* original URL with the addition of a query parameter used for keeping track of
* the revision info.
*
* @param {string} url The URL whose cache key to look up.
* @return {string} The cache key that corresponds to that URL.
*
* @alias workbox.precaching.getCacheKeyForURL
*/
const getCacheKeyForURL$1 = url => {
const precacheController = getOrCreatePrecacheController();
return precacheController.getCacheKeyForURL(url);
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const installListener = event => {
const precacheController = getOrCreatePrecacheController();
const plugins = precachePlugins.get();
event.waitUntil(precacheController.install({
event,
plugins
}).catch(error => {
{
logger_mjs.logger.error(`Service worker installation failed. It will ` + `be retried automatically during the next navigation.`);
} // Re-throw the error to ensure installation fails.
throw error;
}));
};
const activateListener = event => {
const precacheController = getOrCreatePrecacheController();
const plugins = precachePlugins.get();
event.waitUntil(precacheController.activate({
event,
plugins
}));
};
/**
* Adds items to the precache list, removing any duplicates and
* stores the files in the
* ["precache cache"]{@link module:workbox-core.cacheNames} when the service
* worker installs.
*
* This method can be called multiple times.
*
* Please note: This method **will not** serve any of the cached files for you.
* It only precaches files. To respond to a network request you call
* [addRoute()]{@link module:workbox-precaching.addRoute}.
*
* If you have a single array of files to precache, you can just call
* [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.
*
* @param {Array<Object|string>} entries Array of entries to precache.
*
* @alias workbox.precaching.precache
*/
const precache = entries => {
const precacheController = getOrCreatePrecacheController();
precacheController.addToCacheList(entries);
if (entries.length > 0) {
// NOTE: these listeners will only be added once (even if the `precache()`
// method is called multiple times) because event listeners are implemented
// as a set, where each listener must be unique.
addEventListener('install', installListener);
addEventListener('activate', activateListener);
}
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This method will add entries to the precache list and add a route to
* respond to fetch events.
*
* This is a convenience method that will call
* [precache()]{@link module:workbox-precaching.precache} and
* [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.
*
* @param {Array<Object|string>} entries Array of entries to precache.
* @param {Object} options See
* [addRoute() options]{@link module:workbox-precaching.addRoute}.
*
* @alias workbox.precaching.precacheAndRoute
*/
const precacheAndRoute = (entries, options) => {
precache(entries);
addRoute(options);
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
{
assert_mjs.assert.isSWEnv('workbox-precaching');
}
exports.addPlugins = addPlugins;
exports.addRoute = addRoute;
exports.cleanupOutdatedCaches = cleanupOutdatedCaches;
exports.getCacheKeyForURL = getCacheKeyForURL$1;
exports.precache = precache;
exports.precacheAndRoute = precacheAndRoute;
exports.PrecacheController = PrecacheController;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-precaching.dev.js.map
{"version":3,"file":"workbox-precaching.dev.js","sources":["../_version.mjs","../utils/precachePlugins.mjs","../addPlugins.mjs","../utils/cleanRedirect.mjs","../utils/createCacheKey.mjs","../utils/printCleanupDetails.mjs","../utils/printInstallDetails.mjs","../PrecacheController.mjs","../utils/getOrCreatePrecacheController.mjs","../utils/removeIgnoredSearchParams.mjs","../utils/generateURLVariations.mjs","../utils/getCacheKeyForURL.mjs","../utils/addFetchListener.mjs","../addRoute.mjs","../utils/deleteOutdatedCaches.mjs","../cleanupOutdatedCaches.mjs","../getCacheKeyForURL.mjs","../precache.mjs","../precacheAndRoute.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:precaching:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst plugins = [];\n\nexport const precachePlugins = {\n /*\n * @return {Array}\n * @private\n */\n get() {\n return plugins;\n },\n\n /*\n * @param {Array} newPlugins\n * @private\n */\n add(newPlugins) {\n plugins.push(...newPlugins);\n },\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {precachePlugins} from './utils/precachePlugins.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds plugins to precaching.\n *\n * @param {Array<Object>} newPlugins\n *\n * @alias workbox.precaching.addPlugins\n */\nconst addPlugins = (newPlugins) => {\n precachePlugins.add(newPlugins);\n};\n\nexport {addPlugins};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * @param {Response} response\n * @return {Response}\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport async function cleanRedirect(response) {\n const clonedResponse = response.clone();\n\n // Not all browsers support the Response.body stream, so fall back\n // to reading the entire body into memory as a blob.\n const bodyPromise = 'body' in clonedResponse ?\n Promise.resolve(clonedResponse.body) :\n clonedResponse.blob();\n\n const body = await bodyPromise;\n\n // new Response() is happy when passed either a stream or a Blob.\n return new Response(body, {\n headers: clonedResponse.headers,\n status: clonedResponse.status,\n statusText: clonedResponse.statusText,\n });\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport '../_version.mjs';\n\n// Name of the search parameter used to store revision info.\nconst REVISION_SEARCH_PARAM = '__WB_REVISION__';\n\n/**\n * Converts a manifest entry into a versioned URL suitable for precaching.\n *\n * @param {Object} entry\n * @return {string} A URL with versioning info.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function createCacheKey(entry) {\n if (!entry) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', {entry});\n }\n\n // If a precache manifest entry is a string, it's assumed to be a versioned\n // URL, like '/app.abcd1234.js'. Return as-is.\n if (typeof entry === 'string') {\n const urlObject = new URL(entry, location);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n\n const {revision, url} = entry;\n if (!url) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', {entry});\n }\n\n // If there's just a URL and no revision, then it's also assumed to be a\n // versioned URL.\n if (!revision) {\n const urlObject = new URL(url, location);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n\n // Otherwise, construct a properly versioned URL using the custom Workbox\n // search parameter along with the revision info.\n const originalURL = new URL(url, location);\n const cacheKeyURL = new URL(url, location);\n cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);\n return {\n cacheKey: cacheKeyURL.href,\n url: originalURL.href,\n };\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport '../_version.mjs';\n\nconst logGroup = (groupTitle, deletedURLs) => {\n logger.groupCollapsed(groupTitle);\n\n for (const url of deletedURLs) {\n logger.log(url);\n }\n\n logger.groupEnd();\n};\n\n/**\n * @param {Array<string>} deletedURLs\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function printCleanupDetails(deletedURLs) {\n const deletionCount = deletedURLs.length;\n if (deletionCount > 0) {\n logger.groupCollapsed(`During precaching cleanup, ` +\n `${deletionCount} cached ` +\n `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);\n logGroup('Deleted Cache Requests', deletedURLs);\n logger.groupEnd();\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport '../_version.mjs';\n\n/**\n * @param {string} groupTitle\n * @param {Array<string>} urls\n *\n * @private\n */\nfunction _nestedGroup(groupTitle, urls) {\n if (urls.length === 0) {\n return;\n }\n\n logger.groupCollapsed(groupTitle);\n\n for (const url of urls) {\n logger.log(url);\n }\n\n logger.groupEnd();\n}\n\n/**\n * @param {Array<string>} urlsToPrecache\n * @param {Array<string>} urlsAlreadyPrecached\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) {\n const precachedCount = urlsToPrecache.length;\n const alreadyPrecachedCount = urlsAlreadyPrecached.length;\n\n if (precachedCount || alreadyPrecachedCount) {\n let message =\n `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;\n\n if (alreadyPrecachedCount > 0) {\n message += ` ${alreadyPrecachedCount} ` +\n `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;\n }\n\n logger.groupCollapsed(message);\n\n _nestedGroup(`View newly precached URLs.`, urlsToPrecache);\n _nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached);\n logger.groupEnd();\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {cleanRedirect} from './utils/cleanRedirect.mjs';\nimport {createCacheKey} from './utils/createCacheKey.mjs';\nimport {printCleanupDetails} from './utils/printCleanupDetails.mjs';\nimport {printInstallDetails} from './utils/printInstallDetails.mjs';\n\nimport './_version.mjs';\n\n\n/**\n * Performs efficient precaching of assets.\n *\n * @memberof module:workbox-precaching\n */\nclass PrecacheController {\n /**\n * Create a new PrecacheController.\n *\n * @param {string} [cacheName] An optional name for the cache, to override\n * the default precache name.\n */\n constructor(cacheName) {\n this._cacheName = cacheNames.getPrecacheName(cacheName);\n this._urlsToCacheKeys = new Map();\n }\n\n /**\n * This method will add items to the precache list, removing duplicates\n * and ensuring the information is valid.\n *\n * @param {\n * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>\n * } entries Array of entries to precache.\n */\n addToCacheList(entries) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(entries, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'addToCacheList',\n paramName: 'entries',\n });\n }\n\n for (const entry of entries) {\n const {cacheKey, url} = createCacheKey(entry);\n if (this._urlsToCacheKeys.has(url) &&\n this._urlsToCacheKeys.get(url) !== cacheKey) {\n throw new WorkboxError('add-to-cache-list-conflicting-entries', {\n firstEntry: this._urlsToCacheKeys.get(url),\n secondEntry: cacheKey,\n });\n }\n this._urlsToCacheKeys.set(url, cacheKey);\n }\n }\n\n /**\n * Precaches new and updated assets. Call this method from the service worker\n * install event.\n *\n * @param {Object} options\n * @param {Event} [options.event] The install event (if needed).\n * @param {Array<Object>} [options.plugins] Plugins to be used for fetching\n * and caching during install.\n * @return {Promise<workbox.precaching.InstallResult>}\n */\n async install({event, plugins} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (plugins) {\n assert.isArray(plugins, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'install',\n paramName: 'plugins',\n });\n }\n }\n\n const urlsToPrecache = [];\n const urlsAlreadyPrecached = [];\n\n const cache = await caches.open(this._cacheName);\n const alreadyCachedRequests = await cache.keys();\n const alreadyCachedURLs = new Set(alreadyCachedRequests.map(\n (request) => request.url));\n\n for (const cacheKey of this._urlsToCacheKeys.values()) {\n if (alreadyCachedURLs.has(cacheKey)) {\n urlsAlreadyPrecached.push(cacheKey);\n } else {\n urlsToPrecache.push(cacheKey);\n }\n }\n\n const precacheRequests = urlsToPrecache.map((url) => {\n return this._addURLToCache({event, plugins, url});\n });\n await Promise.all(precacheRequests);\n\n if (process.env.NODE_ENV !== 'production') {\n printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);\n }\n\n return {\n updatedURLs: urlsToPrecache,\n notUpdatedURLs: urlsAlreadyPrecached,\n };\n }\n\n /**\n * Deletes assets that are no longer present in the current precache manifest.\n * Call this method from the service worker activate event.\n *\n * @return {Promise<workbox.precaching.CleanupResult>}\n */\n async activate() {\n const cache = await caches.open(this._cacheName);\n const currentlyCachedRequests = await cache.keys();\n const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());\n\n const deletedURLs = [];\n for (const request of currentlyCachedRequests) {\n if (!expectedCacheKeys.has(request.url)) {\n await cache.delete(request);\n deletedURLs.push(request.url);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n printCleanupDetails(deletedURLs);\n }\n\n return {deletedURLs};\n }\n\n /**\n * Requests the entry and saves it to the cache if the response is valid.\n * By default, any response with a status code of less than 400 (including\n * opaque responses) is considered valid.\n *\n * If you need to use custom criteria to determine what's valid and what\n * isn't, then pass in an item in `options.plugins` that implements the\n * `cacheWillUpdate()` lifecycle event.\n *\n * @private\n * @param {Object} options\n * @param {string} options.url The URL to fetch and cache.\n * @param {Event} [options.event] The install event (if passed).\n * @param {Array<Object>} [options.plugins] An array of plugins to apply to\n * fetch and caching.\n */\n async _addURLToCache({url, event, plugins}) {\n const request = new Request(url, {credentials: 'same-origin'});\n let response = await fetchWrapper.fetch({\n event,\n plugins,\n request,\n });\n\n // Allow developers to override the default logic about what is and isn't\n // valid by passing in a plugin implementing cacheWillUpdate(), e.g.\n // a workbox.cacheableResponse.Plugin instance.\n let cacheWillUpdateCallback;\n for (const plugin of (plugins || [])) {\n if ('cacheWillUpdate' in plugin) {\n cacheWillUpdateCallback = plugin.cacheWillUpdate.bind(plugin);\n }\n }\n\n const isValidResponse = cacheWillUpdateCallback ?\n // Use a callback if provided. It returns a truthy value if valid.\n cacheWillUpdateCallback({event, request, response}) :\n // Otherwise, default to considering any response status under 400 valid.\n // This includes, by default, considering opaque responses valid.\n response.status < 400;\n\n // Consider this a failure, leading to the `install` handler failing, if\n // we get back an invalid response.\n if (!isValidResponse) {\n throw new WorkboxError('bad-precaching-response', {\n url,\n status: response.status,\n });\n }\n\n if (response.redirected) {\n response = await cleanRedirect(response);\n }\n\n await cacheWrapper.put({\n event,\n plugins,\n request,\n response,\n cacheName: this._cacheName,\n matchOptions: {\n ignoreSearch: true,\n },\n });\n }\n\n /**\n * Returns a mapping of a precached URL to the corresponding cache key, taking\n * into account the revision information for the URL.\n *\n * @return {Map<string, string>} A URL to cache key mapping.\n */\n getURLsToCacheKeys() {\n return this._urlsToCacheKeys;\n }\n\n /**\n * Returns a list of all the URLs that have been precached by the current\n * service worker.\n *\n * @return {Array<string>} The precached URLs.\n */\n getCachedURLs() {\n return [...this._urlsToCacheKeys.keys()];\n }\n\n /**\n * Returns the cache key used for storing a given URL. If that URL is\n * unversioned, like `/index.html', then the cache key will be the original\n * URL with a search parameter appended to it.\n *\n * @param {string} url A URL whose cache key you want to look up.\n * @return {string} The versioned URL that corresponds to a cache key\n * for the original URL, or undefined if that URL isn't precached.\n */\n getCacheKeyForURL(url) {\n const urlObject = new URL(url, location);\n return this._urlsToCacheKeys.get(urlObject.href);\n }\n}\n\nexport {PrecacheController};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {PrecacheController} from '../PrecacheController.mjs';\nimport '../_version.mjs';\n\n\nlet precacheController;\n\n/**\n * @return {PrecacheController}\n * @private\n */\nexport const getOrCreatePrecacheController = () => {\n if (!precacheController) {\n precacheController = new PrecacheController();\n }\n return precacheController;\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * Removes any URL search parameters that should be ignored.\n *\n * @param {URL} urlObject The original URL.\n * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against\n * each search parameter name. Matches mean that the search parameter should be\n * ignored.\n * @return {URL} The URL with any ignored search parameters removed.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function removeIgnoredSearchParams(urlObject,\n ignoreURLParametersMatching) {\n // Convert the iterable into an array at the start of the loop to make sure\n // deletion doesn't mess up iteration.\n for (const paramName of [...urlObject.searchParams.keys()]) {\n if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) {\n urlObject.searchParams.delete(paramName);\n }\n }\n\n return urlObject;\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {removeIgnoredSearchParams} from './removeIgnoredSearchParams.mjs';\n\nimport '../_version.mjs';\n\n/**\n * Generator function that yields possible variations on the original URL to\n * check, one at a time.\n *\n * @param {string} url\n * @param {Object} options\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function* generateURLVariations(url, {\n ignoreURLParametersMatching,\n directoryIndex,\n cleanURLs,\n urlManipulation,\n} = {}) {\n const urlObject = new URL(url, location);\n urlObject.hash = '';\n yield urlObject.href;\n\n const urlWithoutIgnoredParams = removeIgnoredSearchParams(\n urlObject, ignoreURLParametersMatching);\n yield urlWithoutIgnoredParams.href;\n\n if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {\n const directoryURL = new URL(urlWithoutIgnoredParams);\n directoryURL.pathname += directoryIndex;\n yield directoryURL.href;\n }\n\n if (cleanURLs) {\n const cleanURL = new URL(urlWithoutIgnoredParams);\n cleanURL.pathname += '.html';\n yield cleanURL.href;\n }\n\n if (urlManipulation) {\n const additionalURLs = urlManipulation({url: urlObject});\n for (const urlToAttempt of additionalURLs) {\n yield urlToAttempt.href;\n }\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreatePrecacheController}\n from './getOrCreatePrecacheController.mjs';\nimport {generateURLVariations} from './generateURLVariations.mjs';\nimport '../_version.mjs';\n\n/**\n * This function will take the request URL and manipulate it based on the\n * configuration options.\n *\n * @param {string} url\n * @param {Object} options\n * @return {string} Returns the URL in the cache that matches the request,\n * if possible.\n *\n * @private\n */\nexport const getCacheKeyForURL = (url, options) => {\n const precacheController = getOrCreatePrecacheController();\n\n const urlsToCacheKeys = precacheController.getURLsToCacheKeys();\n for (const possibleURL of generateURLVariations(url, options)) {\n const possibleCacheKey = urlsToCacheKeys.get(possibleURL);\n if (possibleCacheKey) {\n return possibleCacheKey;\n }\n }\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {getCacheKeyForURL} from './getCacheKeyForURL.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Adds a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * NOTE: when called more than once this method will replace the previously set\n * configuration options. Calling it more than once is not recommended outside\n * of tests.\n *\n * @private\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n */\nexport const addFetchListener = ({\n ignoreURLParametersMatching = [/^utm_/],\n directoryIndex = 'index.html',\n cleanURLs = true,\n urlManipulation = null,\n} = {}) => {\n const cacheName = cacheNames.getPrecacheName();\n\n addEventListener('fetch', (event) => {\n const precachedURL = getCacheKeyForURL(event.request.url, {\n cleanURLs,\n directoryIndex,\n ignoreURLParametersMatching,\n urlManipulation,\n });\n if (!precachedURL) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Precaching did not find a match for ` +\n getFriendlyURL(event.request.url));\n }\n return;\n }\n\n let responsePromise = caches.open(cacheName).then((cache) => {\n return cache.match(precachedURL);\n }).then((cachedResponse) => {\n if (cachedResponse) {\n return cachedResponse;\n }\n\n // Fall back to the network if we don't have a cached response\n // (perhaps due to manual cache cleanup).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`The precached response for ` +\n `${getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` +\n `Falling back to the network instead.`);\n }\n\n return fetch(precachedURL);\n });\n\n if (process.env.NODE_ENV !== 'production') {\n responsePromise = responsePromise.then((response) => {\n // Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Precaching is responding to: ` +\n getFriendlyURL(event.request.url));\n logger.log(`Serving the precached url: ${precachedURL}`);\n\n logger.groupCollapsed(`View request details here.`);\n logger.log(event.request);\n logger.groupEnd();\n\n logger.groupCollapsed(`View response details here.`);\n logger.log(response);\n logger.groupEnd();\n\n logger.groupEnd();\n return response;\n });\n }\n\n event.respondWith(responsePromise);\n });\n};\n","\n/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {addFetchListener} from './utils/addFetchListener.mjs';\nimport './_version.mjs';\n\n\nlet listenerAdded = false;\n\n/**\n * Add a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n *\n * @alias workbox.precaching.addRoute\n */\nexport const addRoute = (options) => {\n if (!listenerAdded) {\n addFetchListener(options);\n listenerAdded = true;\n }\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst SUBSTRING_TO_FIND = '-precache-';\n\n/**\n * Cleans up incompatible precaches that were created by older versions of\n * Workbox, by a service worker registered under the current scope.\n *\n * This is meant to be called as part of the `activate` event.\n *\n * This should be safe to use as long as you don't include `substringToFind`\n * (defaulting to `-precache-`) in your non-precache cache names.\n *\n * @param {string} currentPrecacheName The cache name currently in use for\n * precaching. This cache won't be deleted.\n * @param {string} [substringToFind='-precache-'] Cache names which include this\n * substring will be deleted (excluding `currentPrecacheName`).\n * @return {Array<string>} A list of all the cache names that were deleted.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nconst deleteOutdatedCaches = async (\n currentPrecacheName,\n substringToFind = SUBSTRING_TO_FIND) => {\n const cacheNames = await caches.keys();\n\n const cacheNamesToDelete = cacheNames.filter((cacheName) => {\n return cacheName.includes(substringToFind) &&\n cacheName.includes(self.registration.scope) &&\n cacheName !== currentPrecacheName;\n });\n\n await Promise.all(\n cacheNamesToDelete.map((cacheName) => caches.delete(cacheName)));\n\n return cacheNamesToDelete;\n};\n\nexport {deleteOutdatedCaches};\n\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {deleteOutdatedCaches} from './utils/deleteOutdatedCaches.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds an `activate` event listener which will clean up incompatible\n * precaches that were created by older versions of Workbox.\n *\n * @alias workbox.precaching.cleanupOutdatedCaches\n */\nexport const cleanupOutdatedCaches = () => {\n addEventListener('activate', (event) => {\n const cacheName = cacheNames.getPrecacheName();\n\n event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => {\n if (process.env.NODE_ENV !== 'production') {\n if (cachesDeleted.length > 0) {\n logger.log(`The following out-of-date precaches were cleaned up ` +\n `automatically:`, cachesDeleted);\n }\n }\n }));\n });\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreatePrecacheController}\n from './utils/getOrCreatePrecacheController.mjs';\nimport './_version.mjs';\n\n\n/**\n * Takes in a URL, and returns the corresponding URL that could be used to\n * lookup the entry in the precache.\n *\n * If a relative URL is provided, the location of the service worker file will\n * be used as the base.\n *\n * For precached entries without revision information, the cache key will be the\n * same as the original URL.\n *\n * For precached entries with revision information, the cache key will be the\n * original URL with the addition of a query parameter used for keeping track of\n * the revision info.\n *\n * @param {string} url The URL whose cache key to look up.\n * @return {string} The cache key that corresponds to that URL.\n *\n * @alias workbox.precaching.getCacheKeyForURL\n */\nexport const getCacheKeyForURL = (url) => {\n const precacheController = getOrCreatePrecacheController();\n return precacheController.getCacheKeyForURL(url);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {getOrCreatePrecacheController} from './utils/getOrCreatePrecacheController.mjs';\nimport {precachePlugins} from './utils/precachePlugins.mjs';\nimport './_version.mjs';\n\n\nconst installListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n\n event.waitUntil(\n precacheController.install({event, plugins})\n .catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Service worker installation failed. It will ` +\n `be retried automatically during the next navigation.`);\n }\n // Re-throw the error to ensure installation fails.\n throw error;\n })\n );\n};\n\nconst activateListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n\n event.waitUntil(precacheController.activate({event, plugins}));\n};\n\n/**\n * Adds items to the precache list, removing any duplicates and\n * stores the files in the\n * [\"precache cache\"]{@link module:workbox-core.cacheNames} when the service\n * worker installs.\n *\n * This method can be called multiple times.\n *\n * Please note: This method **will not** serve any of the cached files for you.\n * It only precaches files. To respond to a network request you call\n * [addRoute()]{@link module:workbox-precaching.addRoute}.\n *\n * If you have a single array of files to precache, you can just call\n * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n *\n * @alias workbox.precaching.precache\n */\nexport const precache = (entries) => {\n const precacheController = getOrCreatePrecacheController();\n precacheController.addToCacheList(entries);\n\n if (entries.length > 0) {\n // NOTE: these listeners will only be added once (even if the `precache()`\n // method is called multiple times) because event listeners are implemented\n // as a set, where each listener must be unique.\n addEventListener('install', installListener);\n addEventListener('activate', activateListener);\n }\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {addRoute} from './addRoute.mjs';\nimport {precache} from './precache.mjs';\nimport './_version.mjs';\n\n\n/**\n * This method will add entries to the precache list and add a route to\n * respond to fetch events.\n *\n * This is a convenience method that will call\n * [precache()]{@link module:workbox-precaching.precache} and\n * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n * @param {Object} options See\n * [addRoute() options]{@link module:workbox-precaching.addRoute}.\n *\n * @alias workbox.precaching.precacheAndRoute\n */\nexport const precacheAndRoute = (entries, options) => {\n precache(entries);\n addRoute(options);\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {addPlugins} from './addPlugins.mjs';\nimport {addRoute} from './addRoute.mjs';\nimport {cleanupOutdatedCaches} from './cleanupOutdatedCaches.mjs';\nimport {getCacheKeyForURL} from './getCacheKeyForURL.mjs';\nimport {precache} from './precache.mjs';\nimport {precacheAndRoute} from './precacheAndRoute.mjs';\nimport {PrecacheController} from './PrecacheController.mjs';\nimport './_version.mjs';\n\n\nif (process.env.NODE_ENV !== 'production') {\n assert.isSWEnv('workbox-precaching');\n}\n\n/**\n * Most consumers of this module will want to use the\n * [precacheAndRoute()]{@link workbox.precaching.precacheAndRoute}\n * method to add assets to the Cache and respond to network requests with these\n * cached assets.\n *\n * If you require finer grained control, you can use the\n * [PrecacheController]{@link workbox.precaching.PrecacheController}\n * to determine when performed.\n *\n * @namespace workbox.precaching\n */\n\nexport {\n addPlugins,\n addRoute,\n cleanupOutdatedCaches,\n getCacheKeyForURL,\n precache,\n precacheAndRoute,\n PrecacheController,\n};\n"],"names":["self","_","e","plugins","precachePlugins","get","add","newPlugins","push","addPlugins","cleanRedirect","response","clonedResponse","clone","bodyPromise","Promise","resolve","body","blob","Response","headers","status","statusText","REVISION_SEARCH_PARAM","createCacheKey","entry","WorkboxError","urlObject","URL","location","cacheKey","href","url","revision","originalURL","cacheKeyURL","searchParams","set","logGroup","groupTitle","deletedURLs","logger","groupCollapsed","log","groupEnd","printCleanupDetails","deletionCount","length","_nestedGroup","urls","printInstallDetails","urlsToPrecache","urlsAlreadyPrecached","precachedCount","alreadyPrecachedCount","message","PrecacheController","constructor","cacheName","_cacheName","cacheNames","getPrecacheName","_urlsToCacheKeys","Map","addToCacheList","entries","assert","isArray","moduleName","className","funcName","paramName","has","firstEntry","secondEntry","install","event","cache","caches","open","alreadyCachedRequests","keys","alreadyCachedURLs","Set","map","request","values","precacheRequests","_addURLToCache","all","updatedURLs","notUpdatedURLs","activate","currentlyCachedRequests","expectedCacheKeys","delete","Request","credentials","fetchWrapper","fetch","cacheWillUpdateCallback","plugin","cacheWillUpdate","bind","isValidResponse","redirected","cacheWrapper","put","matchOptions","ignoreSearch","getURLsToCacheKeys","getCachedURLs","getCacheKeyForURL","precacheController","getOrCreatePrecacheController","removeIgnoredSearchParams","ignoreURLParametersMatching","some","regExp","test","generateURLVariations","directoryIndex","cleanURLs","urlManipulation","hash","urlWithoutIgnoredParams","pathname","endsWith","directoryURL","cleanURL","additionalURLs","urlToAttempt","options","urlsToCacheKeys","possibleURL","possibleCacheKey","addFetchListener","addEventListener","precachedURL","debug","getFriendlyURL","responsePromise","then","match","cachedResponse","warn","respondWith","listenerAdded","addRoute","SUBSTRING_TO_FIND","deleteOutdatedCaches","currentPrecacheName","substringToFind","cacheNamesToDelete","filter","includes","registration","scope","cleanupOutdatedCaches","waitUntil","cachesDeleted","installListener","catch","error","activateListener","precache","precacheAndRoute","isSWEnv"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,0BAAD,CAAJ,IAAkCC,CAAC,EAAnC;EAAsC,CAA1C,CAA0C,OAAMC,CAAN,EAAQ;;ECAlD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GAA3B,EACK+J,KADL,CACYC,KAAD,IAAW;EAChB,IAA2C;EACzC1H,MAAAA,iBAAM,CAAC0H,KAAP,CAAc,8CAAD,GACZ,sDADD;EAED,KAJe;;;EAMhB,UAAMA,KAAN;EACD,GARL,CADJ;EAWD,CAfD;;EAiBA,MAAMC,gBAAgB,GAAIxF,KAAD,IAAW;EAClC,QAAMqC,kBAAkB,GAAGC,6BAA6B,EAAxD;EACA,QAAM/G,OAAO,GAAGC,eAAe,CAACC,GAAhB,EAAhB;EAEAuE,EAAAA,KAAK,CAACmF,SAAN,CAAgB9C,kBAAkB,CAACrB,QAAnB,CAA4B;EAAChB,IAAAA,KAAD;EAAQzE,IAAAA;EAAR,GAA5B,CAAhB;EACD,CALD;EAOA;;;;;;;;;;;;;;;;;;;;;AAmBA,QAAakK,QAAQ,GAAIpG,OAAD,IAAa;EACnC,QAAMgD,kBAAkB,GAAGC,6BAA6B,EAAxD;EACAD,EAAAA,kBAAkB,CAACjD,cAAnB,CAAkCC,OAAlC;;EAEA,MAAIA,OAAO,CAAClB,MAAR,GAAiB,CAArB,EAAwB;EACtB;EACA;EACA;EACA0F,IAAAA,gBAAgB,CAAC,SAAD,EAAYwB,eAAZ,CAAhB;EACAxB,IAAAA,gBAAgB,CAAC,UAAD,EAAa2B,gBAAb,CAAhB;EACD;EACF,CAXM;;ECzDP;;;;;;;AAQA,EAKA;;;;;;;;;;;;;;;AAcA,QAAaE,gBAAgB,GAAG,CAACrG,OAAD,EAAUmE,OAAV,KAAsB;EACpDiC,EAAAA,QAAQ,CAACpG,OAAD,CAAR;EACAmF,EAAAA,QAAQ,CAAChB,OAAD,CAAR;EACD,CAHM;;EC3BP;;;;;;;AAQA;AAWA,EAA2C;EACzClE,EAAAA,iBAAM,CAACqG,OAAP,CAAe,oBAAf;EACD;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,s,c){"use strict";try{self["workbox:precaching:4.3.1"]&&_()}catch(t){}const o=[],i={get:()=>o,add(t){o.push(...t)}};const a="__WB_REVISION__";function r(t){if(!t)throw new c.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new c.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location);return{cacheKey:t.href,url:t.href}}const s=new URL(n,location),o=new URL(n,location);return o.searchParams.set(a,e),{cacheKey:o.href,url:s.href}}class l{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.s=new Map}addToCacheList(t){for(const e of t){const{cacheKey:t,url:n}=r(e);if(this.s.has(n)&&this.s.get(n)!==t)throw new c.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(n),secondEntry:t});this.s.set(n,t)}}async install({event:t,plugins:e}={}){const n=[],s=[],c=await caches.open(this.t),o=await c.keys(),i=new Set(o.map(t=>t.url));for(const t of this.s.values())i.has(t)?s.push(t):n.push(t);const a=n.map(n=>this.o({event:t,plugins:e,url:n}));return await Promise.all(a),{updatedURLs:n,notUpdatedURLs:s}}async activate(){const t=await caches.open(this.t),e=await t.keys(),n=new Set(this.s.values()),s=[];for(const c of e)n.has(c.url)||(await t.delete(c),s.push(c.url));return{deletedURLs:s}}async o({url:t,event:e,plugins:o}){const i=new Request(t,{credentials:"same-origin"});let a,r=await s.fetchWrapper.fetch({event:e,plugins:o,request:i});for(const t of o||[])"cacheWillUpdate"in t&&(a=t.cacheWillUpdate.bind(t));if(!(a?a({event:e,request:i,response:r}):r.status<400))throw new c.WorkboxError("bad-precaching-response",{url:t,status:r.status});r.redirected&&(r=await async function(t){const e=t.clone(),n="body"in e?Promise.resolve(e.body):e.blob(),s=await n;return new Response(s,{headers:e.headers,status:e.status,statusText:e.statusText})}(r)),await n.cacheWrapper.put({event:e,plugins:o,request:i,response:r,cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(t){const e=new URL(t,location);return this.s.get(e.href)}}let u;const h=()=>(u||(u=new l),u);const d=(t,e)=>{const n=h().getURLsToCacheKeys();for(const s of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:s,urlManipulation:c}={}){const o=new URL(t,location);o.hash="",yield o.href;const i=function(t,e){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(o,e);if(yield i.href,n&&i.pathname.endsWith("/")){const t=new URL(i);t.pathname+=n,yield t.href}if(s){const t=new URL(i);t.pathname+=".html",yield t.href}if(c){const t=c({url:o});for(const e of t)yield e.href}}(t,e)){const t=n.get(s);if(t)return t}};let w=!1;const f=t=>{w||((({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:s=!0,urlManipulation:c=null}={})=>{const o=e.cacheNames.getPrecacheName();addEventListener("fetch",e=>{const i=d(e.request.url,{cleanURLs:s,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:c});if(!i)return;let a=caches.open(o).then(t=>t.match(i)).then(t=>t||fetch(i));e.respondWith(a)})})(t),w=!0)},y=t=>{const e=h(),n=i.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},p=t=>{const e=h(),n=i.get();t.waitUntil(e.activate({event:t,plugins:n}))},L=t=>{h().addToCacheList(t),t.length>0&&(addEventListener("install",y),addEventListener("activate",p))};return t.addPlugins=(t=>{i.add(t)}),t.addRoute=f,t.cleanupOutdatedCaches=(()=>{addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil((async(t,e="-precache-")=>{const n=(await caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>caches.delete(t))),n})(n).then(t=>{}))})}),t.getCacheKeyForURL=(t=>{return h().getCacheKeyForURL(t)}),t.precache=L,t.precacheAndRoute=((t,e)=>{L(t),f(e)}),t.PrecacheController=l,t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-precaching.prod.js.map
{"version":3,"file":"workbox-precaching.prod.js","sources":["../_version.mjs","../utils/precachePlugins.mjs","../utils/createCacheKey.mjs","../PrecacheController.mjs","../utils/cleanRedirect.mjs","../utils/getOrCreatePrecacheController.mjs","../utils/getCacheKeyForURL.mjs","../utils/generateURLVariations.mjs","../utils/removeIgnoredSearchParams.mjs","../addRoute.mjs","../utils/addFetchListener.mjs","../precache.mjs","../addPlugins.mjs","../cleanupOutdatedCaches.mjs","../utils/deleteOutdatedCaches.mjs","../getCacheKeyForURL.mjs","../precacheAndRoute.mjs"],"sourcesContent":["try{self['workbox:precaching:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst plugins = [];\n\nexport const precachePlugins = {\n /*\n * @return {Array}\n * @private\n */\n get() {\n return plugins;\n },\n\n /*\n * @param {Array} newPlugins\n * @private\n */\n add(newPlugins) {\n plugins.push(...newPlugins);\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport '../_version.mjs';\n\n// Name of the search parameter used to store revision info.\nconst REVISION_SEARCH_PARAM = '__WB_REVISION__';\n\n/**\n * Converts a manifest entry into a versioned URL suitable for precaching.\n *\n * @param {Object} entry\n * @return {string} A URL with versioning info.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function createCacheKey(entry) {\n if (!entry) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', {entry});\n }\n\n // If a precache manifest entry is a string, it's assumed to be a versioned\n // URL, like '/app.abcd1234.js'. Return as-is.\n if (typeof entry === 'string') {\n const urlObject = new URL(entry, location);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n\n const {revision, url} = entry;\n if (!url) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', {entry});\n }\n\n // If there's just a URL and no revision, then it's also assumed to be a\n // versioned URL.\n if (!revision) {\n const urlObject = new URL(url, location);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n\n // Otherwise, construct a properly versioned URL using the custom Workbox\n // search parameter along with the revision info.\n const originalURL = new URL(url, location);\n const cacheKeyURL = new URL(url, location);\n cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);\n return {\n cacheKey: cacheKeyURL.href,\n url: originalURL.href,\n };\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {cleanRedirect} from './utils/cleanRedirect.mjs';\nimport {createCacheKey} from './utils/createCacheKey.mjs';\nimport {printCleanupDetails} from './utils/printCleanupDetails.mjs';\nimport {printInstallDetails} from './utils/printInstallDetails.mjs';\n\nimport './_version.mjs';\n\n\n/**\n * Performs efficient precaching of assets.\n *\n * @memberof module:workbox-precaching\n */\nclass PrecacheController {\n /**\n * Create a new PrecacheController.\n *\n * @param {string} [cacheName] An optional name for the cache, to override\n * the default precache name.\n */\n constructor(cacheName) {\n this._cacheName = cacheNames.getPrecacheName(cacheName);\n this._urlsToCacheKeys = new Map();\n }\n\n /**\n * This method will add items to the precache list, removing duplicates\n * and ensuring the information is valid.\n *\n * @param {\n * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>\n * } entries Array of entries to precache.\n */\n addToCacheList(entries) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(entries, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'addToCacheList',\n paramName: 'entries',\n });\n }\n\n for (const entry of entries) {\n const {cacheKey, url} = createCacheKey(entry);\n if (this._urlsToCacheKeys.has(url) &&\n this._urlsToCacheKeys.get(url) !== cacheKey) {\n throw new WorkboxError('add-to-cache-list-conflicting-entries', {\n firstEntry: this._urlsToCacheKeys.get(url),\n secondEntry: cacheKey,\n });\n }\n this._urlsToCacheKeys.set(url, cacheKey);\n }\n }\n\n /**\n * Precaches new and updated assets. Call this method from the service worker\n * install event.\n *\n * @param {Object} options\n * @param {Event} [options.event] The install event (if needed).\n * @param {Array<Object>} [options.plugins] Plugins to be used for fetching\n * and caching during install.\n * @return {Promise<workbox.precaching.InstallResult>}\n */\n async install({event, plugins} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (plugins) {\n assert.isArray(plugins, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'install',\n paramName: 'plugins',\n });\n }\n }\n\n const urlsToPrecache = [];\n const urlsAlreadyPrecached = [];\n\n const cache = await caches.open(this._cacheName);\n const alreadyCachedRequests = await cache.keys();\n const alreadyCachedURLs = new Set(alreadyCachedRequests.map(\n (request) => request.url));\n\n for (const cacheKey of this._urlsToCacheKeys.values()) {\n if (alreadyCachedURLs.has(cacheKey)) {\n urlsAlreadyPrecached.push(cacheKey);\n } else {\n urlsToPrecache.push(cacheKey);\n }\n }\n\n const precacheRequests = urlsToPrecache.map((url) => {\n return this._addURLToCache({event, plugins, url});\n });\n await Promise.all(precacheRequests);\n\n if (process.env.NODE_ENV !== 'production') {\n printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);\n }\n\n return {\n updatedURLs: urlsToPrecache,\n notUpdatedURLs: urlsAlreadyPrecached,\n };\n }\n\n /**\n * Deletes assets that are no longer present in the current precache manifest.\n * Call this method from the service worker activate event.\n *\n * @return {Promise<workbox.precaching.CleanupResult>}\n */\n async activate() {\n const cache = await caches.open(this._cacheName);\n const currentlyCachedRequests = await cache.keys();\n const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());\n\n const deletedURLs = [];\n for (const request of currentlyCachedRequests) {\n if (!expectedCacheKeys.has(request.url)) {\n await cache.delete(request);\n deletedURLs.push(request.url);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n printCleanupDetails(deletedURLs);\n }\n\n return {deletedURLs};\n }\n\n /**\n * Requests the entry and saves it to the cache if the response is valid.\n * By default, any response with a status code of less than 400 (including\n * opaque responses) is considered valid.\n *\n * If you need to use custom criteria to determine what's valid and what\n * isn't, then pass in an item in `options.plugins` that implements the\n * `cacheWillUpdate()` lifecycle event.\n *\n * @private\n * @param {Object} options\n * @param {string} options.url The URL to fetch and cache.\n * @param {Event} [options.event] The install event (if passed).\n * @param {Array<Object>} [options.plugins] An array of plugins to apply to\n * fetch and caching.\n */\n async _addURLToCache({url, event, plugins}) {\n const request = new Request(url, {credentials: 'same-origin'});\n let response = await fetchWrapper.fetch({\n event,\n plugins,\n request,\n });\n\n // Allow developers to override the default logic about what is and isn't\n // valid by passing in a plugin implementing cacheWillUpdate(), e.g.\n // a workbox.cacheableResponse.Plugin instance.\n let cacheWillUpdateCallback;\n for (const plugin of (plugins || [])) {\n if ('cacheWillUpdate' in plugin) {\n cacheWillUpdateCallback = plugin.cacheWillUpdate.bind(plugin);\n }\n }\n\n const isValidResponse = cacheWillUpdateCallback ?\n // Use a callback if provided. It returns a truthy value if valid.\n cacheWillUpdateCallback({event, request, response}) :\n // Otherwise, default to considering any response status under 400 valid.\n // This includes, by default, considering opaque responses valid.\n response.status < 400;\n\n // Consider this a failure, leading to the `install` handler failing, if\n // we get back an invalid response.\n if (!isValidResponse) {\n throw new WorkboxError('bad-precaching-response', {\n url,\n status: response.status,\n });\n }\n\n if (response.redirected) {\n response = await cleanRedirect(response);\n }\n\n await cacheWrapper.put({\n event,\n plugins,\n request,\n response,\n cacheName: this._cacheName,\n matchOptions: {\n ignoreSearch: true,\n },\n });\n }\n\n /**\n * Returns a mapping of a precached URL to the corresponding cache key, taking\n * into account the revision information for the URL.\n *\n * @return {Map<string, string>} A URL to cache key mapping.\n */\n getURLsToCacheKeys() {\n return this._urlsToCacheKeys;\n }\n\n /**\n * Returns a list of all the URLs that have been precached by the current\n * service worker.\n *\n * @return {Array<string>} The precached URLs.\n */\n getCachedURLs() {\n return [...this._urlsToCacheKeys.keys()];\n }\n\n /**\n * Returns the cache key used for storing a given URL. If that URL is\n * unversioned, like `/index.html', then the cache key will be the original\n * URL with a search parameter appended to it.\n *\n * @param {string} url A URL whose cache key you want to look up.\n * @return {string} The versioned URL that corresponds to a cache key\n * for the original URL, or undefined if that URL isn't precached.\n */\n getCacheKeyForURL(url) {\n const urlObject = new URL(url, location);\n return this._urlsToCacheKeys.get(urlObject.href);\n }\n}\n\nexport {PrecacheController};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * @param {Response} response\n * @return {Response}\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport async function cleanRedirect(response) {\n const clonedResponse = response.clone();\n\n // Not all browsers support the Response.body stream, so fall back\n // to reading the entire body into memory as a blob.\n const bodyPromise = 'body' in clonedResponse ?\n Promise.resolve(clonedResponse.body) :\n clonedResponse.blob();\n\n const body = await bodyPromise;\n\n // new Response() is happy when passed either a stream or a Blob.\n return new Response(body, {\n headers: clonedResponse.headers,\n status: clonedResponse.status,\n statusText: clonedResponse.statusText,\n });\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {PrecacheController} from '../PrecacheController.mjs';\nimport '../_version.mjs';\n\n\nlet precacheController;\n\n/**\n * @return {PrecacheController}\n * @private\n */\nexport const getOrCreatePrecacheController = () => {\n if (!precacheController) {\n precacheController = new PrecacheController();\n }\n return precacheController;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreatePrecacheController}\n from './getOrCreatePrecacheController.mjs';\nimport {generateURLVariations} from './generateURLVariations.mjs';\nimport '../_version.mjs';\n\n/**\n * This function will take the request URL and manipulate it based on the\n * configuration options.\n *\n * @param {string} url\n * @param {Object} options\n * @return {string} Returns the URL in the cache that matches the request,\n * if possible.\n *\n * @private\n */\nexport const getCacheKeyForURL = (url, options) => {\n const precacheController = getOrCreatePrecacheController();\n\n const urlsToCacheKeys = precacheController.getURLsToCacheKeys();\n for (const possibleURL of generateURLVariations(url, options)) {\n const possibleCacheKey = urlsToCacheKeys.get(possibleURL);\n if (possibleCacheKey) {\n return possibleCacheKey;\n }\n }\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {removeIgnoredSearchParams} from './removeIgnoredSearchParams.mjs';\n\nimport '../_version.mjs';\n\n/**\n * Generator function that yields possible variations on the original URL to\n * check, one at a time.\n *\n * @param {string} url\n * @param {Object} options\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function* generateURLVariations(url, {\n ignoreURLParametersMatching,\n directoryIndex,\n cleanURLs,\n urlManipulation,\n} = {}) {\n const urlObject = new URL(url, location);\n urlObject.hash = '';\n yield urlObject.href;\n\n const urlWithoutIgnoredParams = removeIgnoredSearchParams(\n urlObject, ignoreURLParametersMatching);\n yield urlWithoutIgnoredParams.href;\n\n if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {\n const directoryURL = new URL(urlWithoutIgnoredParams);\n directoryURL.pathname += directoryIndex;\n yield directoryURL.href;\n }\n\n if (cleanURLs) {\n const cleanURL = new URL(urlWithoutIgnoredParams);\n cleanURL.pathname += '.html';\n yield cleanURL.href;\n }\n\n if (urlManipulation) {\n const additionalURLs = urlManipulation({url: urlObject});\n for (const urlToAttempt of additionalURLs) {\n yield urlToAttempt.href;\n }\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * Removes any URL search parameters that should be ignored.\n *\n * @param {URL} urlObject The original URL.\n * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against\n * each search parameter name. Matches mean that the search parameter should be\n * ignored.\n * @return {URL} The URL with any ignored search parameters removed.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function removeIgnoredSearchParams(urlObject,\n ignoreURLParametersMatching) {\n // Convert the iterable into an array at the start of the loop to make sure\n // deletion doesn't mess up iteration.\n for (const paramName of [...urlObject.searchParams.keys()]) {\n if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) {\n urlObject.searchParams.delete(paramName);\n }\n }\n\n return urlObject;\n}\n","\n/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {addFetchListener} from './utils/addFetchListener.mjs';\nimport './_version.mjs';\n\n\nlet listenerAdded = false;\n\n/**\n * Add a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n *\n * @alias workbox.precaching.addRoute\n */\nexport const addRoute = (options) => {\n if (!listenerAdded) {\n addFetchListener(options);\n listenerAdded = true;\n }\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {getCacheKeyForURL} from './getCacheKeyForURL.mjs';\nimport '../_version.mjs';\n\n\n/**\n * Adds a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * NOTE: when called more than once this method will replace the previously set\n * configuration options. Calling it more than once is not recommended outside\n * of tests.\n *\n * @private\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n */\nexport const addFetchListener = ({\n ignoreURLParametersMatching = [/^utm_/],\n directoryIndex = 'index.html',\n cleanURLs = true,\n urlManipulation = null,\n} = {}) => {\n const cacheName = cacheNames.getPrecacheName();\n\n addEventListener('fetch', (event) => {\n const precachedURL = getCacheKeyForURL(event.request.url, {\n cleanURLs,\n directoryIndex,\n ignoreURLParametersMatching,\n urlManipulation,\n });\n if (!precachedURL) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Precaching did not find a match for ` +\n getFriendlyURL(event.request.url));\n }\n return;\n }\n\n let responsePromise = caches.open(cacheName).then((cache) => {\n return cache.match(precachedURL);\n }).then((cachedResponse) => {\n if (cachedResponse) {\n return cachedResponse;\n }\n\n // Fall back to the network if we don't have a cached response\n // (perhaps due to manual cache cleanup).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`The precached response for ` +\n `${getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` +\n `Falling back to the network instead.`);\n }\n\n return fetch(precachedURL);\n });\n\n if (process.env.NODE_ENV !== 'production') {\n responsePromise = responsePromise.then((response) => {\n // Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Precaching is responding to: ` +\n getFriendlyURL(event.request.url));\n logger.log(`Serving the precached url: ${precachedURL}`);\n\n logger.groupCollapsed(`View request details here.`);\n logger.log(event.request);\n logger.groupEnd();\n\n logger.groupCollapsed(`View response details here.`);\n logger.log(response);\n logger.groupEnd();\n\n logger.groupEnd();\n return response;\n });\n }\n\n event.respondWith(responsePromise);\n });\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {getOrCreatePrecacheController} from './utils/getOrCreatePrecacheController.mjs';\nimport {precachePlugins} from './utils/precachePlugins.mjs';\nimport './_version.mjs';\n\n\nconst installListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n\n event.waitUntil(\n precacheController.install({event, plugins})\n .catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Service worker installation failed. It will ` +\n `be retried automatically during the next navigation.`);\n }\n // Re-throw the error to ensure installation fails.\n throw error;\n })\n );\n};\n\nconst activateListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n\n event.waitUntil(precacheController.activate({event, plugins}));\n};\n\n/**\n * Adds items to the precache list, removing any duplicates and\n * stores the files in the\n * [\"precache cache\"]{@link module:workbox-core.cacheNames} when the service\n * worker installs.\n *\n * This method can be called multiple times.\n *\n * Please note: This method **will not** serve any of the cached files for you.\n * It only precaches files. To respond to a network request you call\n * [addRoute()]{@link module:workbox-precaching.addRoute}.\n *\n * If you have a single array of files to precache, you can just call\n * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n *\n * @alias workbox.precaching.precache\n */\nexport const precache = (entries) => {\n const precacheController = getOrCreatePrecacheController();\n precacheController.addToCacheList(entries);\n\n if (entries.length > 0) {\n // NOTE: these listeners will only be added once (even if the `precache()`\n // method is called multiple times) because event listeners are implemented\n // as a set, where each listener must be unique.\n addEventListener('install', installListener);\n addEventListener('activate', activateListener);\n }\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {precachePlugins} from './utils/precachePlugins.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds plugins to precaching.\n *\n * @param {Array<Object>} newPlugins\n *\n * @alias workbox.precaching.addPlugins\n */\nconst addPlugins = (newPlugins) => {\n precachePlugins.add(newPlugins);\n};\n\nexport {addPlugins};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {deleteOutdatedCaches} from './utils/deleteOutdatedCaches.mjs';\nimport './_version.mjs';\n\n\n/**\n * Adds an `activate` event listener which will clean up incompatible\n * precaches that were created by older versions of Workbox.\n *\n * @alias workbox.precaching.cleanupOutdatedCaches\n */\nexport const cleanupOutdatedCaches = () => {\n addEventListener('activate', (event) => {\n const cacheName = cacheNames.getPrecacheName();\n\n event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => {\n if (process.env.NODE_ENV !== 'production') {\n if (cachesDeleted.length > 0) {\n logger.log(`The following out-of-date precaches were cleaned up ` +\n `automatically:`, cachesDeleted);\n }\n }\n }));\n });\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst SUBSTRING_TO_FIND = '-precache-';\n\n/**\n * Cleans up incompatible precaches that were created by older versions of\n * Workbox, by a service worker registered under the current scope.\n *\n * This is meant to be called as part of the `activate` event.\n *\n * This should be safe to use as long as you don't include `substringToFind`\n * (defaulting to `-precache-`) in your non-precache cache names.\n *\n * @param {string} currentPrecacheName The cache name currently in use for\n * precaching. This cache won't be deleted.\n * @param {string} [substringToFind='-precache-'] Cache names which include this\n * substring will be deleted (excluding `currentPrecacheName`).\n * @return {Array<string>} A list of all the cache names that were deleted.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nconst deleteOutdatedCaches = async (\n currentPrecacheName,\n substringToFind = SUBSTRING_TO_FIND) => {\n const cacheNames = await caches.keys();\n\n const cacheNamesToDelete = cacheNames.filter((cacheName) => {\n return cacheName.includes(substringToFind) &&\n cacheName.includes(self.registration.scope) &&\n cacheName !== currentPrecacheName;\n });\n\n await Promise.all(\n cacheNamesToDelete.map((cacheName) => caches.delete(cacheName)));\n\n return cacheNamesToDelete;\n};\n\nexport {deleteOutdatedCaches};\n\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreatePrecacheController}\n from './utils/getOrCreatePrecacheController.mjs';\nimport './_version.mjs';\n\n\n/**\n * Takes in a URL, and returns the corresponding URL that could be used to\n * lookup the entry in the precache.\n *\n * If a relative URL is provided, the location of the service worker file will\n * be used as the base.\n *\n * For precached entries without revision information, the cache key will be the\n * same as the original URL.\n *\n * For precached entries with revision information, the cache key will be the\n * original URL with the addition of a query parameter used for keeping track of\n * the revision info.\n *\n * @param {string} url The URL whose cache key to look up.\n * @return {string} The cache key that corresponds to that URL.\n *\n * @alias workbox.precaching.getCacheKeyForURL\n */\nexport const getCacheKeyForURL = (url) => {\n const precacheController = getOrCreatePrecacheController();\n return precacheController.getCacheKeyForURL(url);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {addRoute} from './addRoute.mjs';\nimport {precache} from './precache.mjs';\nimport './_version.mjs';\n\n\n/**\n * This method will add entries to the precache list and add a route to\n * respond to fetch events.\n *\n * This is a convenience method that will call\n * [precache()]{@link module:workbox-precaching.precache} and\n * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n * @param {Object} options See\n * [addRoute() options]{@link module:workbox-precaching.addRoute}.\n *\n * @alias workbox.precaching.precacheAndRoute\n */\nexport const precacheAndRoute = (entries, options) => {\n precache(entries);\n addRoute(options);\n};\n"],"names":["self","_","e","plugins","precachePlugins","get","add","newPlugins","push","REVISION_SEARCH_PARAM","createCacheKey","entry","WorkboxError","urlObject","URL","location","cacheKey","href","url","revision","originalURL","cacheKeyURL","searchParams","set","PrecacheController","constructor","cacheName","_cacheName","cacheNames","getPrecacheName","_urlsToCacheKeys","Map","addToCacheList","entries","this","has","firstEntry","secondEntry","event","urlsToPrecache","urlsAlreadyPrecached","cache","caches","open","alreadyCachedRequests","keys","alreadyCachedURLs","Set","map","request","values","precacheRequests","_addURLToCache","Promise","all","updatedURLs","notUpdatedURLs","currentlyCachedRequests","expectedCacheKeys","deletedURLs","delete","Request","credentials","cacheWillUpdateCallback","response","fetchWrapper","fetch","plugin","cacheWillUpdate","bind","status","redirected","async","clonedResponse","clone","bodyPromise","resolve","body","blob","Response","headers","statusText","cleanRedirect","cacheWrapper","put","matchOptions","ignoreSearch","getURLsToCacheKeys","getCachedURLs","getCacheKeyForURL","precacheController","getOrCreatePrecacheController","options","urlsToCacheKeys","possibleURL","ignoreURLParametersMatching","directoryIndex","cleanURLs","urlManipulation","hash","urlWithoutIgnoredParams","paramName","some","regExp","test","removeIgnoredSearchParams","pathname","endsWith","directoryURL","cleanURL","additionalURLs","urlToAttempt","generateURLVariations","possibleCacheKey","listenerAdded","addRoute","addEventListener","precachedURL","responsePromise","then","match","cachedResponse","respondWith","addFetchListener","installListener","waitUntil","install","catch","error","activateListener","activate","precache","length","currentPrecacheName","substringToFind","cacheNamesToDelete","filter","includes","registration","scope","deleteOutdatedCaches","cachesDeleted"],"mappings":"uFAAA,IAAIA,KAAK,6BAA6BC,IAAI,MAAMC,ICWhD,MAAMC,EAAU,GAEHC,EAAkB,CAK7BC,IAAG,IACMF,EAOTG,IAAIC,GACFJ,EAAQK,QAAQD,KCdpB,MAAME,EAAwB,kBAWvB,SAASC,EAAeC,OACxBA,QACG,IAAIC,eAAa,oCAAqC,CAACD,MAAAA,OAK1C,iBAAVA,EAAoB,OACvBE,EAAY,IAAIC,IAAIH,EAAOI,gBAC1B,CACLC,SAAUH,EAAUI,KACpBC,IAAKL,EAAUI,YAIbE,SAACA,EAADD,IAAWA,GAAOP,MACnBO,QACG,IAAIN,eAAa,oCAAqC,CAACD,MAAAA,QAK1DQ,EAAU,OACPN,EAAY,IAAIC,IAAII,EAAKH,gBACxB,CACLC,SAAUH,EAAUI,KACpBC,IAAKL,EAAUI,YAMbG,EAAc,IAAIN,IAAII,EAAKH,UAC3BM,EAAc,IAAIP,IAAII,EAAKH,iBACjCM,EAAYC,aAAaC,IAAId,EAAuBU,GAC7C,CACLH,SAAUK,EAAYJ,KACtBC,IAAKE,EAAYH,MClC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AAOnC,QAAAA,MAsBzCgI,EAAYlG,IACI0D,IACR3D,eAAeC,GAE9BA,EAAQmG,OAAS,IAInBhB,iBAAiB,UAAWQ,GAC5BR,iBAAiB,WAAYa,yBC/Cb1H,CAAAA,IAClBH,EAAgBE,IAAIC,0CCAe,MACnC6G,iBAAiB,WAAa9E,UACtBZ,EAAYE,aAAWC,kBAE7BS,EAAMuF,UCMmBrD,OAC3B6D,EACAC,EAtBwB,sBAyBlBC,SAFmB7F,OAAOG,QAEM2F,OAAQ9G,GACrCA,EAAU+G,SAASH,IACnB5G,EAAU+G,SAASzI,KAAK0I,aAAaC,QACrCjH,IAAc2G,gBAGjBhF,QAAQC,IACViF,EAAmBvF,IAAKtB,GAAcgB,OAAOkB,OAAOlC,KAEjD6G,GDpBWK,CAAqBlH,GAAW6F,KAAMsB,gCEQxB3H,CAAAA,WACLyE,IACDF,kBAAkBvE,qCCPd,EAACe,EAAS2D,KACxCuC,EAASlG,GACTkF,EAASvB"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.rangeRequests = (function (exports, WorkboxError_mjs, assert_mjs, logger_mjs) {
'use strict';
try {
self['workbox:range-requests:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @param {Blob} blob A source blob.
* @param {number|null} start The offset to use as the start of the
* slice.
* @param {number|null} end The offset to use as the end of the slice.
* @return {Object} An object with `start` and `end` properties, reflecting
* the effective boundaries to use given the size of the blob.
*
* @private
*/
function calculateEffectiveBoundaries(blob, start, end) {
{
assert_mjs.assert.isInstance(blob, Blob, {
moduleName: 'workbox-range-requests',
funcName: 'calculateEffectiveBoundaries',
paramName: 'blob'
});
}
const blobSize = blob.size;
if (end > blobSize || start < 0) {
throw new WorkboxError_mjs.WorkboxError('range-not-satisfiable', {
size: blobSize,
end,
start
});
}
let effectiveStart;
let effectiveEnd;
if (start === null) {
effectiveStart = blobSize - end;
effectiveEnd = blobSize;
} else if (end === null) {
effectiveStart = start;
effectiveEnd = blobSize;
} else {
effectiveStart = start; // Range values are inclusive, so add 1 to the value.
effectiveEnd = end + 1;
}
return {
start: effectiveStart,
end: effectiveEnd
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @param {string} rangeHeader A Range: header value.
* @return {Object} An object with `start` and `end` properties, reflecting
* the parsed value of the Range: header. If either the `start` or `end` are
* omitted, then `null` will be returned.
*
* @private
*/
function parseRangeHeader(rangeHeader) {
{
assert_mjs.assert.isType(rangeHeader, 'string', {
moduleName: 'workbox-range-requests',
funcName: 'parseRangeHeader',
paramName: 'rangeHeader'
});
}
const normalizedRangeHeader = rangeHeader.trim().toLowerCase();
if (!normalizedRangeHeader.startsWith('bytes=')) {
throw new WorkboxError_mjs.WorkboxError('unit-must-be-bytes', {
normalizedRangeHeader
});
} // Specifying multiple ranges separate by commas is valid syntax, but this
// library only attempts to handle a single, contiguous sequence of bytes.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax
if (normalizedRangeHeader.includes(',')) {
throw new WorkboxError_mjs.WorkboxError('single-range-only', {
normalizedRangeHeader
});
}
const rangeParts = /(\d*)-(\d*)/.exec(normalizedRangeHeader); // We need either at least one of the start or end values.
if (rangeParts === null || !(rangeParts[1] || rangeParts[2])) {
throw new WorkboxError_mjs.WorkboxError('invalid-range-values', {
normalizedRangeHeader
});
}
return {
start: rangeParts[1] === '' ? null : Number(rangeParts[1]),
end: rangeParts[2] === '' ? null : Number(rangeParts[2])
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Given a `Request` and `Response` objects as input, this will return a
* promise for a new `Response`.
*
* If the original `Response` already contains partial content (i.e. it has
* a status of 206), then this assumes it already fulfills the `Range:`
* requirements, and will return it as-is.
*
* @param {Request} request A request, which should contain a Range:
* header.
* @param {Response} originalResponse A response.
* @return {Promise<Response>} Either a `206 Partial Content` response, with
* the response body set to the slice of content specified by the request's
* `Range:` header, or a `416 Range Not Satisfiable` response if the
* conditions of the `Range:` header can't be met.
*
* @memberof workbox.rangeRequests
*/
async function createPartialResponse(request, originalResponse) {
try {
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-range-requests',
funcName: 'createPartialResponse',
paramName: 'request'
});
assert_mjs.assert.isInstance(originalResponse, Response, {
moduleName: 'workbox-range-requests',
funcName: 'createPartialResponse',
paramName: 'originalResponse'
});
}
if (originalResponse.status === 206) {
// If we already have a 206, then just pass it through as-is;
// see https://github.com/GoogleChrome/workbox/issues/1720
return originalResponse;
}
const rangeHeader = request.headers.get('range');
if (!rangeHeader) {
throw new WorkboxError_mjs.WorkboxError('no-range-header');
}
const boundaries = parseRangeHeader(rangeHeader);
const originalBlob = await originalResponse.blob();
const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);
const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);
const slicedBlobSize = slicedBlob.size;
const slicedResponse = new Response(slicedBlob, {
// Status code 206 is for a Partial Content response.
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206
status: 206,
statusText: 'Partial Content',
headers: originalResponse.headers
});
slicedResponse.headers.set('Content-Length', slicedBlobSize);
slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` + originalBlob.size);
return slicedResponse;
} catch (error) {
{
logger_mjs.logger.warn(`Unable to construct a partial response; returning a ` + `416 Range Not Satisfiable response instead.`);
logger_mjs.logger.groupCollapsed(`View details here.`);
logger_mjs.logger.log(error);
logger_mjs.logger.log(request);
logger_mjs.logger.log(originalResponse);
logger_mjs.logger.groupEnd();
}
return new Response('', {
status: 416,
statusText: 'Range Not Satisfiable'
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The range request plugin makes it easy for a request with a 'Range' header to
* be fulfilled by a cached response.
*
* It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
* and returning the appropriate subset of the cached response body.
*
* @memberof workbox.rangeRequests
*/
class Plugin {
/**
* @param {Object} options
* @param {Request} options.request The original request, which may or may not
* contain a Range: header.
* @param {Response} options.cachedResponse The complete cached response.
* @return {Promise<Response>} If request contains a 'Range' header, then a
* new response with status 206 whose body is a subset of `cachedResponse` is
* returned. Otherwise, `cachedResponse` is returned as-is.
*
* @private
*/
async cachedResponseWillBeUsed({
request,
cachedResponse
}) {
// Only return a sliced response if there's something valid in the cache,
// and there's a Range: header in the request.
if (cachedResponse && request.headers.has('range')) {
return await createPartialResponse(request, cachedResponse);
} // If there was no Range: header, or if cachedResponse wasn't valid, just
// pass it through as-is.
return cachedResponse;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.createPartialResponse = createPartialResponse;
exports.Plugin = Plugin;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-range-requests.dev.js.map
{"version":3,"file":"workbox-range-requests.dev.js","sources":["../_version.mjs","../utils/calculateEffectiveBoundaries.mjs","../utils/parseRangeHeader.mjs","../createPartialResponse.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:range-requests:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport '../_version.mjs';\n\n/**\n * @param {Blob} blob A source blob.\n * @param {number|null} start The offset to use as the start of the\n * slice.\n * @param {number|null} end The offset to use as the end of the slice.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the effective boundaries to use given the size of the blob.\n *\n * @private\n */\nfunction calculateEffectiveBoundaries(blob, start, end) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(blob, Blob, {\n moduleName: 'workbox-range-requests',\n funcName: 'calculateEffectiveBoundaries',\n paramName: 'blob',\n });\n }\n\n const blobSize = blob.size;\n\n if (end > blobSize || start < 0) {\n throw new WorkboxError('range-not-satisfiable', {\n size: blobSize,\n end,\n start,\n });\n }\n\n let effectiveStart;\n let effectiveEnd;\n\n if (start === null) {\n effectiveStart = blobSize - end;\n effectiveEnd = blobSize;\n } else if (end === null) {\n effectiveStart = start;\n effectiveEnd = blobSize;\n } else {\n effectiveStart = start;\n // Range values are inclusive, so add 1 to the value.\n effectiveEnd = end + 1;\n }\n\n return {\n start: effectiveStart,\n end: effectiveEnd,\n };\n}\n\nexport {calculateEffectiveBoundaries};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport '../_version.mjs';\n\n/**\n * @param {string} rangeHeader A Range: header value.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the parsed value of the Range: header. If either the `start` or `end` are\n * omitted, then `null` will be returned.\n *\n * @private\n */\nfunction parseRangeHeader(rangeHeader) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(rangeHeader, 'string', {\n moduleName: 'workbox-range-requests',\n funcName: 'parseRangeHeader',\n paramName: 'rangeHeader',\n });\n }\n\n const normalizedRangeHeader = rangeHeader.trim().toLowerCase();\n if (!normalizedRangeHeader.startsWith('bytes=')) {\n throw new WorkboxError('unit-must-be-bytes', {normalizedRangeHeader});\n }\n\n // Specifying multiple ranges separate by commas is valid syntax, but this\n // library only attempts to handle a single, contiguous sequence of bytes.\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax\n if (normalizedRangeHeader.includes(',')) {\n throw new WorkboxError('single-range-only', {normalizedRangeHeader});\n }\n\n const rangeParts = /(\\d*)-(\\d*)/.exec(normalizedRangeHeader);\n // We need either at least one of the start or end values.\n if (rangeParts === null || !(rangeParts[1] || rangeParts[2])) {\n throw new WorkboxError('invalid-range-values', {normalizedRangeHeader});\n }\n\n return {\n start: rangeParts[1] === '' ? null : Number(rangeParts[1]),\n end: rangeParts[2] === '' ? null : Number(rangeParts[2]),\n };\n}\n\nexport {parseRangeHeader};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {calculateEffectiveBoundaries} from\n './utils/calculateEffectiveBoundaries.mjs';\nimport {parseRangeHeader} from './utils/parseRangeHeader.mjs';\n\nimport './_version.mjs';\n\n/**\n * Given a `Request` and `Response` objects as input, this will return a\n * promise for a new `Response`.\n *\n * If the original `Response` already contains partial content (i.e. it has\n * a status of 206), then this assumes it already fulfills the `Range:`\n * requirements, and will return it as-is.\n *\n * @param {Request} request A request, which should contain a Range:\n * header.\n * @param {Response} originalResponse A response.\n * @return {Promise<Response>} Either a `206 Partial Content` response, with\n * the response body set to the slice of content specified by the request's\n * `Range:` header, or a `416 Range Not Satisfiable` response if the\n * conditions of the `Range:` header can't be met.\n *\n * @memberof workbox.rangeRequests\n */\nasync function createPartialResponse(request, originalResponse) {\n try {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'request',\n });\n\n assert.isInstance(originalResponse, Response, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'originalResponse',\n });\n }\n\n if (originalResponse.status === 206) {\n // If we already have a 206, then just pass it through as-is;\n // see https://github.com/GoogleChrome/workbox/issues/1720\n return originalResponse;\n }\n\n const rangeHeader = request.headers.get('range');\n if (!rangeHeader) {\n throw new WorkboxError('no-range-header');\n }\n\n const boundaries = parseRangeHeader(rangeHeader);\n const originalBlob = await originalResponse.blob();\n\n const effectiveBoundaries = calculateEffectiveBoundaries(\n originalBlob, boundaries.start, boundaries.end);\n\n const slicedBlob = originalBlob.slice(effectiveBoundaries.start,\n effectiveBoundaries.end);\n const slicedBlobSize = slicedBlob.size;\n\n const slicedResponse = new Response(slicedBlob, {\n // Status code 206 is for a Partial Content response.\n // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206\n status: 206,\n statusText: 'Partial Content',\n headers: originalResponse.headers,\n });\n\n slicedResponse.headers.set('Content-Length', slicedBlobSize);\n slicedResponse.headers.set('Content-Range',\n `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` +\n originalBlob.size);\n\n return slicedResponse;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to construct a partial response; returning a ` +\n `416 Range Not Satisfiable response instead.`);\n logger.groupCollapsed(`View details here.`);\n logger.log(error);\n logger.log(request);\n logger.log(originalResponse);\n logger.groupEnd();\n }\n\n return new Response('', {\n status: 416,\n statusText: 'Range Not Satisfiable',\n });\n }\n}\n\nexport {createPartialResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {createPartialResponse} from './createPartialResponse.mjs';\n\nimport './_version.mjs';\n\n/**\n * The range request plugin makes it easy for a request with a 'Range' header to\n * be fulfilled by a cached response.\n *\n * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback\n * and returning the appropriate subset of the cached response body.\n *\n * @memberof workbox.rangeRequests\n */\nclass Plugin {\n /**\n * @param {Object} options\n * @param {Request} options.request The original request, which may or may not\n * contain a Range: header.\n * @param {Response} options.cachedResponse The complete cached response.\n * @return {Promise<Response>} If request contains a 'Range' header, then a\n * new response with status 206 whose body is a subset of `cachedResponse` is\n * returned. Otherwise, `cachedResponse` is returned as-is.\n *\n * @private\n */\n async cachedResponseWillBeUsed({request, cachedResponse}) {\n // Only return a sliced response if there's something valid in the cache,\n // and there's a Range: header in the request.\n if (cachedResponse && request.headers.has('range')) {\n return await createPartialResponse(request, cachedResponse);\n }\n\n // If there was no Range: header, or if cachedResponse wasn't valid, just\n // pass it through as-is.\n return cachedResponse;\n }\n}\n\nexport {Plugin};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {createPartialResponse} from './createPartialResponse.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.rangeRequests\n */\n\nexport {\n createPartialResponse,\n Plugin,\n};\n"],"names":["self","_","e","calculateEffectiveBoundaries","blob","start","end","assert","isInstance","Blob","moduleName","funcName","paramName","blobSize","size","WorkboxError","effectiveStart","effectiveEnd","parseRangeHeader","rangeHeader","isType","normalizedRangeHeader","trim","toLowerCase","startsWith","includes","rangeParts","exec","Number","createPartialResponse","request","originalResponse","Request","Response","status","headers","get","boundaries","originalBlob","effectiveBoundaries","slicedBlob","slice","slicedBlobSize","slicedResponse","statusText","set","error","logger","warn","groupCollapsed","log","groupEnd","Plugin","cachedResponseWillBeUsed","cachedResponse","has"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,8BAAD,CAAJ,IAAsCC,CAAC,EAAvC;EAA0C,CAA9C,CAA8C,OAAMC,CAAN,EAAQ;;ECAtD;;;;;;;AAQA,EAKA;;;;;;;;;;;EAUA,SAASC,4BAAT,CAAsCC,IAAtC,EAA4CC,KAA5C,EAAmDC,GAAnD,EAAwD;EACtD,EAA2C;EACzCC,IAAAA,iBAAM,CAAC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AAmB,CAAClC,KAAM,IAAGkC,mBAAmB,CAACjC,GAApB,GAA0B,CAAE,GAAlE,GACFgC,YAAY,CAACxB,IAFf;EAIA,WAAO6B,cAAP;EACD,GAlDD,CAkDE,OAAOG,KAAP,EAAc;EACd,IAA2C;EACzCC,MAAAA,iBAAM,CAACC,IAAP,CAAa,sDAAD,GACT,6CADH;EAEAD,MAAAA,iBAAM,CAACE,cAAP,CAAuB,oBAAvB;EACAF,MAAAA,iBAAM,CAACG,GAAP,CAAWJ,KAAX;EACAC,MAAAA,iBAAM,CAACG,GAAP,CAAWpB,OAAX;EACAiB,MAAAA,iBAAM,CAACG,GAAP,CAAWnB,gBAAX;EACAgB,MAAAA,iBAAM,CAACI,QAAP;EACD;;EAED,WAAO,IAAIlB,QAAJ,CAAa,EAAb,EAAiB;EACtBC,MAAAA,MAAM,EAAE,GADc;EAEtBU,MAAAA,UAAU,EAAE;EAFU,KAAjB,CAAP;EAID;EACF;;ECvGD;;;;;;;AAQA,EAIA;;;;;;;;;;EASA,MAAMQ,MAAN,CAAa;EACX;;;;;;;;;;;EAWA,QAAMC,wBAAN,CAA+B;EAACvB,IAAAA,OAAD;EAAUwB,IAAAA;EAAV,GAA/B,EAA0D;EACxD;EACA;EACA,QAAIA,cAAc,IAAIxB,OAAO,CAACK,OAAR,CAAgBoB,GAAhB,CAAoB,OAApB,CAAtB,EAAoD;EAClD,aAAO,MAAM1B,qBAAqB,CAACC,OAAD,EAAUwB,cAAV,CAAlC;EACD,KALuD;EAQxD;;;EACA,WAAOA,cAAP;EACD;;EAtBU;;ECrBb;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.rangeRequests=function(e,n){"use strict";try{self["workbox:range-requests:4.3.1"]&&_()}catch(e){}async function t(e,t){try{if(206===t.status)return t;const s=e.headers.get("range");if(!s)throw new n.WorkboxError("no-range-header");const a=function(e){const t=e.trim().toLowerCase();if(!t.startsWith("bytes="))throw new n.WorkboxError("unit-must-be-bytes",{normalizedRangeHeader:t});if(t.includes(","))throw new n.WorkboxError("single-range-only",{normalizedRangeHeader:t});const s=/(\d*)-(\d*)/.exec(t);if(null===s||!s[1]&&!s[2])throw new n.WorkboxError("invalid-range-values",{normalizedRangeHeader:t});return{start:""===s[1]?null:Number(s[1]),end:""===s[2]?null:Number(s[2])}}(s),r=await t.blob(),i=function(e,t,s){const a=e.size;if(s>a||t<0)throw new n.WorkboxError("range-not-satisfiable",{size:a,end:s,start:t});let r,i;return null===t?(r=a-s,i=a):null===s?(r=t,i=a):(r=t,i=s+1),{start:r,end:i}}(r,a.start,a.end),o=r.slice(i.start,i.end),u=o.size,l=new Response(o,{status:206,statusText:"Partial Content",headers:t.headers});return l.headers.set("Content-Length",u),l.headers.set("Content-Range",`bytes ${i.start}-${i.end-1}/`+r.size),l}catch(e){return new Response("",{status:416,statusText:"Range Not Satisfiable"})}}return e.createPartialResponse=t,e.Plugin=class{async cachedResponseWillBeUsed({request:e,cachedResponse:n}){return n&&e.headers.has("range")?await t(e,n):n}},e}({},workbox.core._private);
//# sourceMappingURL=workbox-range-requests.prod.js.map
{"version":3,"file":"workbox-range-requests.prod.js","sources":["../_version.mjs","../createPartialResponse.mjs","../utils/parseRangeHeader.mjs","../utils/calculateEffectiveBoundaries.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:range-requests:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {calculateEffectiveBoundaries} from\n './utils/calculateEffectiveBoundaries.mjs';\nimport {parseRangeHeader} from './utils/parseRangeHeader.mjs';\n\nimport './_version.mjs';\n\n/**\n * Given a `Request` and `Response` objects as input, this will return a\n * promise for a new `Response`.\n *\n * If the original `Response` already contains partial content (i.e. it has\n * a status of 206), then this assumes it already fulfills the `Range:`\n * requirements, and will return it as-is.\n *\n * @param {Request} request A request, which should contain a Range:\n * header.\n * @param {Response} originalResponse A response.\n * @return {Promise<Response>} Either a `206 Partial Content` response, with\n * the response body set to the slice of content specified by the request's\n * `Range:` header, or a `416 Range Not Satisfiable` response if the\n * conditions of the `Range:` header can't be met.\n *\n * @memberof workbox.rangeRequests\n */\nasync function createPartialResponse(request, originalResponse) {\n try {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'request',\n });\n\n assert.isInstance(originalResponse, Response, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'originalResponse',\n });\n }\n\n if (originalResponse.status === 206) {\n // If we already have a 206, then just pass it through as-is;\n // see https://github.com/GoogleChrome/workbox/issues/1720\n return originalResponse;\n }\n\n const rangeHeader = request.headers.get('range');\n if (!rangeHeader) {\n throw new WorkboxError('no-range-header');\n }\n\n const boundaries = parseRangeHeader(rangeHeader);\n const originalBlob = await originalResponse.blob();\n\n const effectiveBoundaries = calculateEffectiveBoundaries(\n originalBlob, boundaries.start, boundaries.end);\n\n const slicedBlob = originalBlob.slice(effectiveBoundaries.start,\n effectiveBoundaries.end);\n const slicedBlobSize = slicedBlob.size;\n\n const slicedResponse = new Response(slicedBlob, {\n // Status code 206 is for a Partial Content response.\n // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206\n status: 206,\n statusText: 'Partial Content',\n headers: originalResponse.headers,\n });\n\n slicedResponse.headers.set('Content-Length', slicedBlobSize);\n slicedResponse.headers.set('Content-Range',\n `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` +\n originalBlob.size);\n\n return slicedResponse;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to construct a partial response; returning a ` +\n `416 Range Not Satisfiable response instead.`);\n logger.groupCollapsed(`View details here.`);\n logger.log(error);\n logger.log(request);\n logger.log(originalResponse);\n logger.groupEnd();\n }\n\n return new Response('', {\n status: 416,\n statusText: 'Range Not Satisfiable',\n });\n }\n}\n\nexport {createPartialResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport '../_version.mjs';\n\n/**\n * @param {string} rangeHeader A Range: header value.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the parsed value of the Range: header. If either the `start` or `end` are\n * omitted, then `null` will be returned.\n *\n * @private\n */\nfunction parseRangeHeader(rangeHeader) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(rangeHeader, 'string', {\n moduleName: 'workbox-range-requests',\n funcName: 'parseRangeHeader',\n paramName: 'rangeHeader',\n });\n }\n\n const normalizedRangeHeader = rangeHeader.trim().toLowerCase();\n if (!normalizedRangeHeader.startsWith('bytes=')) {\n throw new WorkboxError('unit-must-be-bytes', {normalizedRangeHeader});\n }\n\n // Specifying multiple ranges separate by commas is valid syntax, but this\n // library only attempts to handle a single, contiguous sequence of bytes.\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax\n if (normalizedRangeHeader.includes(',')) {\n throw new WorkboxError('single-range-only', {normalizedRangeHeader});\n }\n\n const rangeParts = /(\\d*)-(\\d*)/.exec(normalizedRangeHeader);\n // We need either at least one of the start or end values.\n if (rangeParts === null || !(rangeParts[1] || rangeParts[2])) {\n throw new WorkboxError('invalid-range-values', {normalizedRangeHeader});\n }\n\n return {\n start: rangeParts[1] === '' ? null : Number(rangeParts[1]),\n end: rangeParts[2] === '' ? null : Number(rangeParts[2]),\n };\n}\n\nexport {parseRangeHeader};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport '../_version.mjs';\n\n/**\n * @param {Blob} blob A source blob.\n * @param {number|null} start The offset to use as the start of the\n * slice.\n * @param {number|null} end The offset to use as the end of the slice.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the effective boundaries to use given the size of the blob.\n *\n * @private\n */\nfunction calculateEffectiveBoundaries(blob, start, end) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(blob, Blob, {\n moduleName: 'workbox-range-requests',\n funcName: 'calculateEffectiveBoundaries',\n paramName: 'blob',\n });\n }\n\n const blobSize = blob.size;\n\n if (end > blobSize || start < 0) {\n throw new WorkboxError('range-not-satisfiable', {\n size: blobSize,\n end,\n start,\n });\n }\n\n let effectiveStart;\n let effectiveEnd;\n\n if (start === null) {\n effectiveStart = blobSize - end;\n effectiveEnd = blobSize;\n } else if (end === null) {\n effectiveStart = start;\n effectiveEnd = blobSize;\n } else {\n effectiveStart = start;\n // Range values are inclusive, so add 1 to the value.\n effectiveEnd = end + 1;\n }\n\n return {\n start: effectiveStart,\n end: effectiveEnd,\n };\n}\n\nexport {calculateEffectiveBoundaries};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {createPartialResponse} from './createPartialResponse.mjs';\n\nimport './_version.mjs';\n\n/**\n * The range request plugin makes it easy for a request with a 'Range' header to\n * be fulfilled by a cached response.\n *\n * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback\n * and returning the appropriate subset of the cached response body.\n *\n * @memberof workbox.rangeRequests\n */\nclass Plugin {\n /**\n * @param {Object} options\n * @param {Request} options.request The original request, which may or may not\n * contain a Range: header.\n * @param {Response} options.cachedResponse The complete cached response.\n * @return {Promise<Response>} If request contains a 'Range' header, then a\n * new response with status 206 whose body is a subset of `cachedResponse` is\n * returned. Otherwise, `cachedResponse` is returned as-is.\n *\n * @private\n */\n async cachedResponseWillBeUsed({request, cachedResponse}) {\n // Only return a sliced response if there's something valid in the cache,\n // and there's a Range: header in the request.\n if (cachedResponse && request.headers.has('range')) {\n return await createPartialResponse(request, cachedResponse);\n }\n\n // If there was no Range: header, or if cachedResponse wasn't valid, just\n // pass it through as-is.\n return cachedResponse;\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","async","createPartialResponse","request","originalResponse","status","rangeHeader","headers","get","WorkboxError","boundaries","normalizedRangeHeader","trim","toLowerCase","startsWith","includes","rangeParts","exec","start","Number","end","parseRangeHeader","originalBlob","blob","effectiveBoundaries","blobSize","size","effectiveStart","effectiveEnd","calculateEffectiveBoundaries","slicedBlob","slice","slicedBlobSize","slicedResponse","Response","statusText","set","error","cachedResponse","has"],"mappings":"oFAAA,IAAIA,KAAK,iCAAiCC,IAAI,MAAMC,ICoCpDC,eAAeC,EAAsBC,EAASC,UAgBV,MAA5BA,EAAiBC,cAGZD,QAGHE,EAAcH,EAAQI,QAAQC,IAAI,aACnCF,QACG,IAAIG,eAAa,yBAGnBC,EC1CV,SAA0BJ,SASlBK,EAAwBL,EAAYM,OAAOC,kBAC5CF,EAAsBG,WAAW,gBAC9B,IAAIL,eAAa,qBAAsB,CAACE,sBAAAA,OAM5CA,EAAsBI,SAAS,WAC3B,IAAIN,eAAa,oBAAqB,CAACE,sBAAAA,UAGzCK,EAAa,cAAcC,KAAKN,MAEnB,OAAfK,IAAyBA,EAAW,KAAMA,EAAW,SACjD,IAAIP,eAAa,uBAAwB,CAACE,sBAAAA,UAG3C,CACLO,MAAyB,KAAlBF,EAAW,GAAY,KAAOG,OAAOH,EAAW,IACvDI,IAAuB,KAAlBJ,EAAW,GAAY,KAAOG,OAAOH,EAAW,KDalCK,CAAiBf,GAC9BgB,QAAqBlB,EAAiBmB,OAEtCC,EE3CV,SAAsCD,EAAML,EAAOE,SAS3CK,EAAWF,EAAKG,QAElBN,EAAMK,GAAYP,EAAQ,QACtB,IAAIT,eAAa,wBAAyB,CAC9CiB,KAAMD,EACNL,IAAAA,EACAF,MAAAA,QAIAS,EACAC,SAEU,OAAVV,GACFS,EAAiBF,EAAWL,EAC5BQ,EAAeH,GACE,OAARL,GACTO,EAAiBT,EACjBU,EAAeH,IAEfE,EAAiBT,EAEjBU,EAAeR,EAAM,GAGhB,CACLF,MAAOS,EACPP,IAAKQ,GFOuBC,CACxBP,EAAcZ,EAAWQ,MAAOR,EAAWU,KAEzCU,EAAaR,EAAaS,MAAMP,EAAoBN,MACtDM,EAAoBJ,KAClBY,EAAiBF,EAAWJ,KAE5BO,EAAiB,IAAIC,SAASJ,EAAY,CAG9CzB,OAAQ,IACR8B,WAAY,kBACZ5B,QAASH,EAAiBG,iBAG5B0B,EAAe1B,QAAQ6B,IAAI,iBAAkBJ,GAC7CC,EAAe1B,QAAQ6B,IAAI,yBACdZ,EAAoBN,SAASM,EAAoBJ,IAAM,KAClEE,EAAaI,MAERO,EACP,MAAOI,UAWA,IAAIH,SAAS,GAAI,CACtB7B,OAAQ,IACR8B,WAAY,qEG/ElB,sCAYiChC,QAACA,EAADmC,eAAUA,WAGnCA,GAAkBnC,EAAQI,QAAQgC,IAAI,eAC3BrC,EAAsBC,EAASmC,GAKvCA"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.routing = (function (exports, assert_mjs, logger_mjs, cacheNames_mjs, WorkboxError_mjs, getFriendlyURL_mjs) {
'use strict';
try {
self['workbox:routing:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The default HTTP method, 'GET', used when there's no specific method
* configured for a route.
*
* @type {string}
*
* @private
*/
const defaultMethod = 'GET';
/**
* The list of valid HTTP methods associated with requests that could be routed.
*
* @type {Array<string>}
*
* @private
*/
const validMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'];
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* @param {function()|Object} handler Either a function, or an object with a
* 'handle' method.
* @return {Object} An object with a handle method.
*
* @private
*/
const normalizeHandler = handler => {
if (handler && typeof handler === 'object') {
{
assert_mjs.assert.hasMethod(handler, 'handle', {
moduleName: 'workbox-routing',
className: 'Route',
funcName: 'constructor',
paramName: 'handler'
});
}
return handler;
} else {
{
assert_mjs.assert.isType(handler, 'function', {
moduleName: 'workbox-routing',
className: 'Route',
funcName: 'constructor',
paramName: 'handler'
});
}
return {
handle: handler
};
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A `Route` consists of a pair of callback functions, "match" and "handler".
* The "match" callback determine if a route should be used to "handle" a
* request by returning a non-falsy value if it can. The "handler" callback
* is called when there is a match and should return a Promise that resolves
* to a `Response`.
*
* @memberof workbox.routing
*/
class Route {
/**
* Constructor for Route class.
*
* @param {workbox.routing.Route~matchCallback} match
* A callback function that determines whether the route matches a given
* `fetch` event by returning a non-falsy value.
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resolving to a Response.
* @param {string} [method='GET'] The HTTP method to match the Route
* against.
*/
constructor(match, handler, method) {
{
assert_mjs.assert.isType(match, 'function', {
moduleName: 'workbox-routing',
className: 'Route',
funcName: 'constructor',
paramName: 'match'
});
if (method) {
assert_mjs.assert.isOneOf(method, validMethods, {
paramName: 'method'
});
}
} // These values are referenced directly by Router so cannot be
// altered by minifification.
this.handler = normalizeHandler(handler);
this.match = match;
this.method = method || defaultMethod;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* NavigationRoute makes it easy to create a [Route]{@link
* workbox.routing.Route} that matches for browser
* [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.
*
* It will only match incoming Requests whose
* [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}
* is set to `navigate`.
*
* You can optionally only apply this route to a subset of navigation requests
* by using one or both of the `blacklist` and `whitelist` parameters.
*
* @memberof workbox.routing
* @extends workbox.routing.Route
*/
class NavigationRoute extends Route {
/**
* If both `blacklist` and `whiltelist` are provided, the `blacklist` will
* take precedence and the request will not match this route.
*
* The regular expressions in `whitelist` and `blacklist`
* are matched against the concatenated
* [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}
* and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}
* portions of the requested URL.
*
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
* @param {Object} options
* @param {Array<RegExp>} [options.blacklist] If any of these patterns match,
* the route will not handle the request (even if a whitelist RegExp matches).
* @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
* match the URL's pathname and search parameter, the route will handle the
* request (assuming the blacklist doesn't match).
*/
constructor(handler, {
whitelist = [/./],
blacklist = []
} = {}) {
{
assert_mjs.assert.isArrayOfClass(whitelist, RegExp, {
moduleName: 'workbox-routing',
className: 'NavigationRoute',
funcName: 'constructor',
paramName: 'options.whitelist'
});
assert_mjs.assert.isArrayOfClass(blacklist, RegExp, {
moduleName: 'workbox-routing',
className: 'NavigationRoute',
funcName: 'constructor',
paramName: 'options.blacklist'
});
}
super(options => this._match(options), handler);
this._whitelist = whitelist;
this._blacklist = blacklist;
}
/**
* Routes match handler.
*
* @param {Object} options
* @param {URL} options.url
* @param {Request} options.request
* @return {boolean}
*
* @private
*/
_match({
url,
request
}) {
if (request.mode !== 'navigate') {
return false;
}
const pathnameAndSearch = url.pathname + url.search;
for (const regExp of this._blacklist) {
if (regExp.test(pathnameAndSearch)) {
{
logger_mjs.logger.log(`The navigation route is not being used, since the ` + `URL matches this blacklist pattern: ${regExp}`);
}
return false;
}
}
if (this._whitelist.some(regExp => regExp.test(pathnameAndSearch))) {
{
logger_mjs.logger.debug(`The navigation route is being used.`);
}
return true;
}
{
logger_mjs.logger.log(`The navigation route is not being used, since the URL ` + `being navigated to doesn't match the whitelist.`);
}
return false;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* RegExpRoute makes it easy to create a regular expression based
* [Route]{@link workbox.routing.Route}.
*
* For same-origin requests the RegExp only needs to match part of the URL. For
* requests against third-party servers, you must define a RegExp that matches
* the start of the URL.
*
* [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}
*
* @memberof workbox.routing
* @extends workbox.routing.Route
*/
class RegExpRoute extends Route {
/**
* If the regulard expression contains
* [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},
* th ecaptured values will be passed to the
* [handler's]{@link workbox.routing.Route~handlerCallback} `params`
* argument.
*
* @param {RegExp} regExp The regular expression to match against URLs.
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
* @param {string} [method='GET'] The HTTP method to match the Route
* against.
*/
constructor(regExp, handler, method) {
{
assert_mjs.assert.isInstance(regExp, RegExp, {
moduleName: 'workbox-routing',
className: 'RegExpRoute',
funcName: 'constructor',
paramName: 'pattern'
});
}
const match = ({
url
}) => {
const result = regExp.exec(url.href); // Return null immediately if there's no match.
if (!result) {
return null;
} // Require that the match start at the first character in the URL string
// if it's a cross-origin request.
// See https://github.com/GoogleChrome/workbox/issues/281 for the context
// behind this behavior.
if (url.origin !== location.origin && result.index !== 0) {
{
logger_mjs.logger.debug(`The regular expression '${regExp}' only partially matched ` + `against the cross-origin URL '${url}'. RegExpRoute's will only ` + `handle cross-origin requests if they match the entire URL.`);
}
return null;
} // If the route matches, but there aren't any capture groups defined, then
// this will return [], which is truthy and therefore sufficient to
// indicate a match.
// If there are capture groups, then it will return their values.
return result.slice(1);
};
super(match, handler, method);
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The Router can be used to process a FetchEvent through one or more
* [Routes]{@link workbox.routing.Route} responding with a Request if
* a matching route exists.
*
* If no route matches a given a request, the Router will use a "default"
* handler if one is defined.
*
* Should the matching Route throw an error, the Router will use a "catch"
* handler if one is defined to gracefully deal with issues and respond with a
* Request.
*
* If a request matches multiple routes, the **earliest** registered route will
* be used to respond to the request.
*
* @memberof workbox.routing
*/
class Router {
/**
* Initializes a new Router.
*/
constructor() {
this._routes = new Map();
}
/**
* @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP
* method name ('GET', etc.) to an array of all the corresponding `Route`
* instances that are registered.
*/
get routes() {
return this._routes;
}
/**
* Adds a fetch event listener to respond to events when a route matches
* the event's request.
*/
addFetchListener() {
self.addEventListener('fetch', event => {
const {
request
} = event;
const responsePromise = this.handleRequest({
request,
event
});
if (responsePromise) {
event.respondWith(responsePromise);
}
});
}
/**
* Adds a message event listener for URLs to cache from the window.
* This is useful to cache resources loaded on the page prior to when the
* service worker started controlling it.
*
* The format of the message data sent from the window should be as follows.
* Where the `urlsToCache` array may consist of URL strings or an array of
* URL string + `requestInit` object (the same as you'd pass to `fetch()`).
*
* ```
* {
* type: 'CACHE_URLS',
* payload: {
* urlsToCache: [
* './script1.js',
* './script2.js',
* ['./script3.js', {mode: 'no-cors'}],
* ],
* },
* }
* ```
*/
addCacheListener() {
self.addEventListener('message', async event => {
if (event.data && event.data.type === 'CACHE_URLS') {
const {
payload
} = event.data;
{
logger_mjs.logger.debug(`Caching URLs from the window`, payload.urlsToCache);
}
const requestPromises = Promise.all(payload.urlsToCache.map(entry => {
if (typeof entry === 'string') {
entry = [entry];
}
const request = new Request(...entry);
return this.handleRequest({
request
});
}));
event.waitUntil(requestPromises); // If a MessageChannel was used, reply to the message on success.
if (event.ports && event.ports[0]) {
await requestPromises;
event.ports[0].postMessage(true);
}
}
});
}
/**
* Apply the routing rules to a FetchEvent object to get a Response from an
* appropriate Route's handler.
*
* @param {Object} options
* @param {Request} options.request The request to handle (this is usually
* from a fetch event, but it does not have to be).
* @param {FetchEvent} [options.event] The event that triggered the request,
* if applicable.
* @return {Promise<Response>|undefined} A promise is returned if a
* registered route can handle the request. If there is no matching
* route and there's no `defaultHandler`, `undefined` is returned.
*/
handleRequest({
request,
event
}) {
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'handleRequest',
paramName: 'options.request'
});
}
const url = new URL(request.url, location);
if (!url.protocol.startsWith('http')) {
{
logger_mjs.logger.debug(`Workbox Router only supports URLs that start with 'http'.`);
}
return;
}
let {
params,
route
} = this.findMatchingRoute({
url,
request,
event
});
let handler = route && route.handler;
let debugMessages = [];
{
if (handler) {
debugMessages.push([`Found a route to handle this request:`, route]);
if (params) {
debugMessages.push([`Passing the following params to the route's handler:`, params]);
}
}
} // If we don't have a handler because there was no matching route, then
// fall back to defaultHandler if that's defined.
if (!handler && this._defaultHandler) {
{
debugMessages.push(`Failed to find a matching route. Falling ` + `back to the default handler.`); // This is used for debugging in logs in the case of an error.
route = '[Default Handler]';
}
handler = this._defaultHandler;
}
if (!handler) {
{
// No handler so Workbox will do nothing. If logs is set of debug
// i.e. verbose, we should print out this information.
logger_mjs.logger.debug(`No route found for: ${getFriendlyURL_mjs.getFriendlyURL(url)}`);
}
return;
}
{
// We have a handler, meaning Workbox is going to handle the route.
// print the routing details to the console.
logger_mjs.logger.groupCollapsed(`Router is responding to: ${getFriendlyURL_mjs.getFriendlyURL(url)}`);
debugMessages.forEach(msg => {
if (Array.isArray(msg)) {
logger_mjs.logger.log(...msg);
} else {
logger_mjs.logger.log(msg);
}
}); // The Request and Response objects contains a great deal of information,
// hide it under a group in case developers want to see it.
logger_mjs.logger.groupCollapsed(`View request details here.`);
logger_mjs.logger.log(request);
logger_mjs.logger.groupEnd();
logger_mjs.logger.groupEnd();
} // Wrap in try and catch in case the handle method throws a synchronous
// error. It should still callback to the catch handler.
let responsePromise;
try {
responsePromise = handler.handle({
url,
request,
event,
params
});
} catch (err) {
responsePromise = Promise.reject(err);
}
if (responsePromise && this._catchHandler) {
responsePromise = responsePromise.catch(err => {
{
// Still include URL here as it will be async from the console group
// and may not make sense without the URL
logger_mjs.logger.groupCollapsed(`Error thrown when responding to: ` + ` ${getFriendlyURL_mjs.getFriendlyURL(url)}. Falling back to Catch Handler.`);
logger_mjs.logger.error(`Error thrown by:`, route);
logger_mjs.logger.error(err);
logger_mjs.logger.groupEnd();
}
return this._catchHandler.handle({
url,
event,
err
});
});
}
return responsePromise;
}
/**
* Checks a request and URL (and optionally an event) against the list of
* registered routes, and if there's a match, returns the corresponding
* route along with any params generated by the match.
*
* @param {Object} options
* @param {URL} options.url
* @param {Request} options.request The request to match.
* @param {FetchEvent} [options.event] The corresponding event (unless N/A).
* @return {Object} An object with `route` and `params` properties.
* They are populated if a matching route was found or `undefined`
* otherwise.
*/
findMatchingRoute({
url,
request,
event
}) {
{
assert_mjs.assert.isInstance(url, URL, {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'findMatchingRoute',
paramName: 'options.url'
});
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'findMatchingRoute',
paramName: 'options.request'
});
}
const routes = this._routes.get(request.method) || [];
for (const route of routes) {
let params;
let matchResult = route.match({
url,
request,
event
});
if (matchResult) {
if (Array.isArray(matchResult) && matchResult.length > 0) {
// Instead of passing an empty array in as params, use undefined.
params = matchResult;
} else if (matchResult.constructor === Object && Object.keys(matchResult).length > 0) {
// Instead of passing an empty object in as params, use undefined.
params = matchResult;
} // Return early if have a match.
return {
route,
params
};
}
} // If no match was found above, return and empty object.
return {};
}
/**
* Define a default `handler` that's called when no routes explicitly
* match the incoming request.
*
* Without a default handler, unmatched requests will go against the
* network as if there were no service worker present.
*
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
*/
setDefaultHandler(handler) {
this._defaultHandler = normalizeHandler(handler);
}
/**
* If a Route throws an error while handling a request, this `handler`
* will be called and given a chance to provide a response.
*
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
*/
setCatchHandler(handler) {
this._catchHandler = normalizeHandler(handler);
}
/**
* Registers a route with the router.
*
* @param {workbox.routing.Route} route The route to register.
*/
registerRoute(route) {
{
assert_mjs.assert.isType(route, 'object', {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'registerRoute',
paramName: 'route'
});
assert_mjs.assert.hasMethod(route, 'match', {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'registerRoute',
paramName: 'route'
});
assert_mjs.assert.isType(route.handler, 'object', {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'registerRoute',
paramName: 'route'
});
assert_mjs.assert.hasMethod(route.handler, 'handle', {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'registerRoute',
paramName: 'route.handler'
});
assert_mjs.assert.isType(route.method, 'string', {
moduleName: 'workbox-routing',
className: 'Router',
funcName: 'registerRoute',
paramName: 'route.method'
});
}
if (!this._routes.has(route.method)) {
this._routes.set(route.method, []);
} // Give precedence to all of the earlier routes by adding this additional
// route to the end of the array.
this._routes.get(route.method).push(route);
}
/**
* Unregisters a route with the router.
*
* @param {workbox.routing.Route} route The route to unregister.
*/
unregisterRoute(route) {
if (!this._routes.has(route.method)) {
throw new WorkboxError_mjs.WorkboxError('unregister-route-but-not-found-with-method', {
method: route.method
});
}
const routeIndex = this._routes.get(route.method).indexOf(route);
if (routeIndex > -1) {
this._routes.get(route.method).splice(routeIndex, 1);
} else {
throw new WorkboxError_mjs.WorkboxError('unregister-route-route-not-registered');
}
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
let defaultRouter;
/**
* Creates a new, singleton Router instance if one does not exist. If one
* does already exist, that instance is returned.
*
* @private
* @return {Router}
*/
const getOrCreateDefaultRouter = () => {
if (!defaultRouter) {
defaultRouter = new Router(); // The helpers that use the default Router assume these listeners exist.
defaultRouter.addFetchListener();
defaultRouter.addCacheListener();
}
return defaultRouter;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Registers a route that will return a precached file for a navigation
* request. This is useful for the
* [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.
*
* When determining the URL of the precached HTML document, you will likely need
* to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for
* the fact that Workbox's precaching naming conventions often results in URL
* cache keys that contain extra revisioning info.
*
* This method will generate a
* [NavigationRoute]{@link workbox.routing.NavigationRoute}
* and call
* [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a
* singleton Router instance.
*
* @param {string} cachedAssetUrl The cache key to use for the HTML file.
* @param {Object} [options]
* @param {string} [options.cacheName] Cache name to store and retrieve
* requests. Defaults to precache cache name provided by
* [workbox-core.cacheNames]{@link workbox.core.cacheNames}.
* @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns
* match, the route will not handle the request (even if a whitelist entry
* matches).
* @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
* match the URL's pathname and search parameter, the route will handle the
* request (assuming the blacklist doesn't match).
* @return {workbox.routing.NavigationRoute} Returns the generated
* Route.
*
* @alias workbox.routing.registerNavigationRoute
*/
const registerNavigationRoute = (cachedAssetUrl, options = {}) => {
{
assert_mjs.assert.isType(cachedAssetUrl, 'string', {
moduleName: 'workbox-routing',
funcName: 'registerNavigationRoute',
paramName: 'cachedAssetUrl'
});
}
const cacheName = cacheNames_mjs.cacheNames.getPrecacheName(options.cacheName);
const handler = async () => {
try {
const response = await caches.match(cachedAssetUrl, {
cacheName
});
if (response) {
return response;
} // This shouldn't normally happen, but there are edge cases:
// https://github.com/GoogleChrome/workbox/issues/1441
throw new Error(`The cache ${cacheName} did not have an entry for ` + `${cachedAssetUrl}.`);
} catch (error) {
// If there's either a cache miss, or the caches.match() call threw
// an exception, then attempt to fulfill the navigation request with
// a response from the network rather than leaving the user with a
// failed navigation.
{
logger_mjs.logger.debug(`Unable to respond to navigation request with ` + `cached response. Falling back to network.`, error);
} // This might still fail if the browser is offline...
return fetch(cachedAssetUrl);
}
};
const route = new NavigationRoute(handler, {
whitelist: options.whitelist,
blacklist: options.blacklist
});
const defaultRouter = getOrCreateDefaultRouter();
defaultRouter.registerRoute(route);
return route;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Easily register a RegExp, string, or function with a caching
* strategy to a singleton Router instance.
*
* This method will generate a Route for you if needed and
* call [Router.registerRoute()]{@link
* workbox.routing.Router#registerRoute}.
*
* @param {
* RegExp|
* string|
* workbox.routing.Route~matchCallback|
* workbox.routing.Route
* } capture
* If the capture param is a `Route`, all other arguments will be ignored.
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
* @param {string} [method='GET'] The HTTP method to match the Route
* against.
* @return {workbox.routing.Route} The generated `Route`(Useful for
* unregistering).
*
* @alias workbox.routing.registerRoute
*/
const registerRoute = (capture, handler, method = 'GET') => {
let route;
if (typeof capture === 'string') {
const captureUrl = new URL(capture, location);
{
if (!(capture.startsWith('/') || capture.startsWith('http'))) {
throw new WorkboxError_mjs.WorkboxError('invalid-string', {
moduleName: 'workbox-routing',
funcName: 'registerRoute',
paramName: 'capture'
});
} // We want to check if Express-style wildcards are in the pathname only.
// TODO: Remove this log message in v4.
const valueToCheck = capture.startsWith('http') ? captureUrl.pathname : capture; // See https://github.com/pillarjs/path-to-regexp#parameters
const wildcards = '[*:?+]';
if (valueToCheck.match(new RegExp(`${wildcards}`))) {
logger_mjs.logger.debug(`The '$capture' parameter contains an Express-style wildcard ` + `character (${wildcards}). Strings are now always interpreted as ` + `exact matches; use a RegExp for partial or wildcard matches.`);
}
}
const matchCallback = ({
url
}) => {
{
if (url.pathname === captureUrl.pathname && url.origin !== captureUrl.origin) {
logger_mjs.logger.debug(`${capture} only partially matches the cross-origin URL ` + `${url}. This route will only handle cross-origin requests ` + `if they match the entire URL.`);
}
}
return url.href === captureUrl.href;
};
route = new Route(matchCallback, handler, method);
} else if (capture instanceof RegExp) {
route = new RegExpRoute(capture, handler, method);
} else if (typeof capture === 'function') {
route = new Route(capture, handler, method);
} else if (capture instanceof Route) {
route = capture;
} else {
throw new WorkboxError_mjs.WorkboxError('unsupported-route-type', {
moduleName: 'workbox-routing',
funcName: 'registerRoute',
paramName: 'capture'
});
}
const defaultRouter = getOrCreateDefaultRouter();
defaultRouter.registerRoute(route);
return route;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* If a Route throws an error while handling a request, this `handler`
* will be called and given a chance to provide a response.
*
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
*
* @alias workbox.routing.setCatchHandler
*/
const setCatchHandler = handler => {
const defaultRouter = getOrCreateDefaultRouter();
defaultRouter.setCatchHandler(handler);
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Define a default `handler` that's called when no routes explicitly
* match the incoming request.
*
* Without a default handler, unmatched requests will go against the
* network as if there were no service worker present.
*
* @param {workbox.routing.Route~handlerCallback} handler A callback
* function that returns a Promise resulting in a Response.
*
* @alias workbox.routing.setDefaultHandler
*/
const setDefaultHandler = handler => {
const defaultRouter = getOrCreateDefaultRouter();
defaultRouter.setDefaultHandler(handler);
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
{
assert_mjs.assert.isSWEnv('workbox-routing');
}
exports.NavigationRoute = NavigationRoute;
exports.RegExpRoute = RegExpRoute;
exports.registerNavigationRoute = registerNavigationRoute;
exports.registerRoute = registerRoute;
exports.Route = Route;
exports.Router = Router;
exports.setCatchHandler = setCatchHandler;
exports.setDefaultHandler = setDefaultHandler;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-routing.dev.js.map
{"version":3,"file":"workbox-routing.dev.js","sources":["../_version.mjs","../utils/constants.mjs","../utils/normalizeHandler.mjs","../Route.mjs","../NavigationRoute.mjs","../RegExpRoute.mjs","../Router.mjs","../utils/getOrCreateDefaultRouter.mjs","../registerNavigationRoute.mjs","../registerRoute.mjs","../setCatchHandler.mjs","../setDefaultHandler.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:routing:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * The default HTTP method, 'GET', used when there's no specific method\n * configured for a route.\n *\n * @type {string}\n *\n * @private\n */\nexport const defaultMethod = 'GET';\n\n/**\n * The list of valid HTTP methods associated with requests that could be routed.\n *\n * @type {Array<string>}\n *\n * @private\n */\nexport const validMethods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'PATCH',\n 'POST',\n 'PUT',\n];\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n/**\n * @param {function()|Object} handler Either a function, or an object with a\n * 'handle' method.\n * @return {Object} An object with a handle method.\n *\n * @private\n */\nexport const normalizeHandler = (handler) => {\n if (handler && typeof handler === 'object') {\n if (process.env.NODE_ENV !== 'production') {\n assert.hasMethod(handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return handler;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(handler, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return {handle: handler};\n }\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {defaultMethod, validMethods} from './utils/constants.mjs';\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * A `Route` consists of a pair of callback functions, \"match\" and \"handler\".\n * The \"match\" callback determine if a route should be used to \"handle\" a\n * request by returning a non-falsy value if it can. The \"handler\" callback\n * is called when there is a match and should return a Promise that resolves\n * to a `Response`.\n *\n * @memberof workbox.routing\n */\nclass Route {\n /**\n * Constructor for Route class.\n *\n * @param {workbox.routing.Route~matchCallback} match\n * A callback function that determines whether the route matches a given\n * `fetch` event by returning a non-falsy value.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resolving to a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(match, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(match, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'match',\n });\n\n if (method) {\n assert.isOneOf(method, validMethods, {paramName: 'method'});\n }\n }\n\n // These values are referenced directly by Router so cannot be\n // altered by minifification.\n this.handler = normalizeHandler(handler);\n this.match = match;\n this.method = method || defaultMethod;\n }\n}\n\nexport {Route};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * NavigationRoute makes it easy to create a [Route]{@link\n * workbox.routing.Route} that matches for browser\n * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.\n *\n * It will only match incoming Requests whose\n * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}\n * is set to `navigate`.\n *\n * You can optionally only apply this route to a subset of navigation requests\n * by using one or both of the `blacklist` and `whitelist` parameters.\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass NavigationRoute extends Route {\n /**\n * If both `blacklist` and `whiltelist` are provided, the `blacklist` will\n * take precedence and the request will not match this route.\n *\n * The regular expressions in `whitelist` and `blacklist`\n * are matched against the concatenated\n * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}\n * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}\n * portions of the requested URL.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {Object} options\n * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,\n * the route will not handle the request (even if a whitelist RegExp matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n */\n constructor(handler, {whitelist = [/./], blacklist = []} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArrayOfClass(whitelist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.whitelist',\n });\n assert.isArrayOfClass(blacklist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.blacklist',\n });\n }\n\n super((options) => this._match(options), handler);\n\n this._whitelist = whitelist;\n this._blacklist = blacklist;\n }\n\n /**\n * Routes match handler.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request\n * @return {boolean}\n *\n * @private\n */\n _match({url, request}) {\n if (request.mode !== 'navigate') {\n return false;\n }\n\n const pathnameAndSearch = url.pathname + url.search;\n\n for (const regExp of this._blacklist) {\n if (regExp.test(pathnameAndSearch)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the ` +\n `URL matches this blacklist pattern: ${regExp}`);\n }\n return false;\n }\n }\n\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route is being used.`);\n }\n return true;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the URL ` +\n `being navigated to doesn't match the whitelist.`);\n }\n return false;\n }\n}\n\nexport {NavigationRoute};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * RegExpRoute makes it easy to create a regular expression based\n * [Route]{@link workbox.routing.Route}.\n *\n * For same-origin requests the RegExp only needs to match part of the URL. For\n * requests against third-party servers, you must define a RegExp that matches\n * the start of the URL.\n *\n * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass RegExpRoute extends Route {\n /**\n * If the regulard expression contains\n * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},\n * th ecaptured values will be passed to the\n * [handler's]{@link workbox.routing.Route~handlerCallback} `params`\n * argument.\n *\n * @param {RegExp} regExp The regular expression to match against URLs.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(regExp, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(regExp, RegExp, {\n moduleName: 'workbox-routing',\n className: 'RegExpRoute',\n funcName: 'constructor',\n paramName: 'pattern',\n });\n }\n\n const match = ({url}) => {\n const result = regExp.exec(url.href);\n\n // Return null immediately if there's no match.\n if (!result) {\n return null;\n }\n\n // Require that the match start at the first character in the URL string\n // if it's a cross-origin request.\n // See https://github.com/GoogleChrome/workbox/issues/281 for the context\n // behind this behavior.\n if ((url.origin !== location.origin) && (result.index !== 0)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `The regular expression '${regExp}' only partially matched ` +\n `against the cross-origin URL '${url}'. RegExpRoute's will only ` +\n `handle cross-origin requests if they match the entire URL.`\n );\n }\n\n return null;\n }\n\n // If the route matches, but there aren't any capture groups defined, then\n // this will return [], which is truthy and therefore sufficient to\n // indicate a match.\n // If there are capture groups, then it will return their values.\n return result.slice(1);\n };\n\n super(match, handler, method);\n }\n}\n\nexport {RegExpRoute};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\n\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * The Router can be used to process a FetchEvent through one or more\n * [Routes]{@link workbox.routing.Route} responding with a Request if\n * a matching route exists.\n *\n * If no route matches a given a request, the Router will use a \"default\"\n * handler if one is defined.\n *\n * Should the matching Route throw an error, the Router will use a \"catch\"\n * handler if one is defined to gracefully deal with issues and respond with a\n * Request.\n *\n * If a request matches multiple routes, the **earliest** registered route will\n * be used to respond to the request.\n *\n * @memberof workbox.routing\n */\nclass Router {\n /**\n * Initializes a new Router.\n */\n constructor() {\n this._routes = new Map();\n }\n\n /**\n * @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP\n * method name ('GET', etc.) to an array of all the corresponding `Route`\n * instances that are registered.\n */\n get routes() {\n return this._routes;\n }\n\n /**\n * Adds a fetch event listener to respond to events when a route matches\n * the event's request.\n */\n addFetchListener() {\n self.addEventListener('fetch', (event) => {\n const {request} = event;\n const responsePromise = this.handleRequest({request, event});\n if (responsePromise) {\n event.respondWith(responsePromise);\n }\n });\n }\n\n /**\n * Adds a message event listener for URLs to cache from the window.\n * This is useful to cache resources loaded on the page prior to when the\n * service worker started controlling it.\n *\n * The format of the message data sent from the window should be as follows.\n * Where the `urlsToCache` array may consist of URL strings or an array of\n * URL string + `requestInit` object (the same as you'd pass to `fetch()`).\n *\n * ```\n * {\n * type: 'CACHE_URLS',\n * payload: {\n * urlsToCache: [\n * './script1.js',\n * './script2.js',\n * ['./script3.js', {mode: 'no-cors'}],\n * ],\n * },\n * }\n * ```\n */\n addCacheListener() {\n self.addEventListener('message', async (event) => {\n if (event.data && event.data.type === 'CACHE_URLS') {\n const {payload} = event.data;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n\n const request = new Request(...entry);\n return this.handleRequest({request});\n }));\n\n event.waitUntil(requestPromises);\n\n // If a MessageChannel was used, reply to the message on success.\n if (event.ports && event.ports[0]) {\n await requestPromises;\n event.ports[0].postMessage(true);\n }\n }\n });\n }\n\n /**\n * Apply the routing rules to a FetchEvent object to get a Response from an\n * appropriate Route's handler.\n *\n * @param {Object} options\n * @param {Request} options.request The request to handle (this is usually\n * from a fetch event, but it does not have to be).\n * @param {FetchEvent} [options.event] The event that triggered the request,\n * if applicable.\n * @return {Promise<Response>|undefined} A promise is returned if a\n * registered route can handle the request. If there is no matching\n * route and there's no `defaultHandler`, `undefined` is returned.\n */\n handleRequest({request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'handleRequest',\n paramName: 'options.request',\n });\n }\n\n const url = new URL(request.url, location);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n\n let {params, route} = this.findMatchingRoute({url, request, event});\n let handler = route && route.handler;\n\n let debugMessages = [];\n if (process.env.NODE_ENV !== 'production') {\n if (handler) {\n debugMessages.push([\n `Found a route to handle this request:`, route,\n ]);\n\n if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\n ]);\n }\n }\n }\n\n // If we don't have a handler because there was no matching route, then\n // fall back to defaultHandler if that's defined.\n if (!handler && this._defaultHandler) {\n if (process.env.NODE_ENV !== 'production') {\n debugMessages.push(`Failed to find a matching route. Falling ` +\n `back to the default handler.`);\n\n // This is used for debugging in logs in the case of an error.\n route = '[Default Handler]';\n }\n handler = this._defaultHandler;\n }\n\n if (!handler) {\n if (process.env.NODE_ENV !== 'production') {\n // No handler so Workbox will do nothing. If logs is set of debug\n // i.e. verbose, we should print out this information.\n logger.debug(`No route found for: ${getFriendlyURL(url)}`);\n }\n return;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // We have a handler, meaning Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Router is responding to: ${getFriendlyURL(url)}`);\n debugMessages.forEach((msg) => {\n if (Array.isArray(msg)) {\n logger.log(...msg);\n } else {\n logger.log(msg);\n }\n });\n\n // The Request and Response objects contains a great deal of information,\n // hide it under a group in case developers want to see it.\n logger.groupCollapsed(`View request details here.`);\n logger.log(request);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n\n // Wrap in try and catch in case the handle method throws a synchronous\n // error. It should still callback to the catch handler.\n let responsePromise;\n try {\n responsePromise = handler.handle({url, request, event, params});\n } catch (err) {\n responsePromise = Promise.reject(err);\n }\n\n if (responsePromise && this._catchHandler) {\n responsePromise = responsePromise.catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // Still include URL here as it will be async from the console group\n // and may not make sense without the URL\n logger.groupCollapsed(`Error thrown when responding to: ` +\n ` ${getFriendlyURL(url)}. Falling back to Catch Handler.`);\n logger.error(`Error thrown by:`, route);\n logger.error(err);\n logger.groupEnd();\n }\n return this._catchHandler.handle({url, event, err});\n });\n }\n\n return responsePromise;\n }\n\n /**\n * Checks a request and URL (and optionally an event) against the list of\n * registered routes, and if there's a match, returns the corresponding\n * route along with any params generated by the match.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request The request to match.\n * @param {FetchEvent} [options.event] The corresponding event (unless N/A).\n * @return {Object} An object with `route` and `params` properties.\n * They are populated if a matching route was found or `undefined`\n * otherwise.\n */\n findMatchingRoute({url, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(url, URL, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.url',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.request',\n });\n }\n\n const routes = this._routes.get(request.method) || [];\n for (const route of routes) {\n let params;\n let matchResult = route.match({url, request, event});\n if (matchResult) {\n if (Array.isArray(matchResult) && matchResult.length > 0) {\n // Instead of passing an empty array in as params, use undefined.\n params = matchResult;\n } else if ((matchResult.constructor === Object &&\n Object.keys(matchResult).length > 0)) {\n // Instead of passing an empty object in as params, use undefined.\n params = matchResult;\n }\n\n // Return early if have a match.\n return {route, params};\n }\n }\n // If no match was found above, return and empty object.\n return {};\n }\n\n /**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setDefaultHandler(handler) {\n this._defaultHandler = normalizeHandler(handler);\n }\n\n /**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setCatchHandler(handler) {\n this._catchHandler = normalizeHandler(handler);\n }\n\n /**\n * Registers a route with the router.\n *\n * @param {workbox.routing.Route} route The route to register.\n */\n registerRoute(route) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(route, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\n }\n\n // Give precedence to all of the earlier routes by adding this additional\n // route to the end of the array.\n this._routes.get(route.method).push(route);\n }\n\n /**\n * Unregisters a route with the router.\n *\n * @param {workbox.routing.Route} route The route to unregister.\n */\n unregisterRoute(route) {\n if (!this._routes.has(route.method)) {\n throw new WorkboxError(\n 'unregister-route-but-not-found-with-method', {\n method: route.method,\n }\n );\n }\n\n const routeIndex = this._routes.get(route.method).indexOf(route);\n if (routeIndex > -1) {\n this._routes.get(route.method).splice(routeIndex, 1);\n } else {\n throw new WorkboxError('unregister-route-route-not-registered');\n }\n }\n}\n\nexport {Router};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Router} from '../Router.mjs';\nimport '../_version.mjs';\n\nlet defaultRouter;\n\n/**\n * Creates a new, singleton Router instance if one does not exist. If one\n * does already exist, that instance is returned.\n *\n * @private\n * @return {Router}\n */\nexport const getOrCreateDefaultRouter = () => {\n if (!defaultRouter) {\n defaultRouter = new Router();\n\n // The helpers that use the default Router assume these listeners exist.\n defaultRouter.addFetchListener();\n defaultRouter.addCacheListener();\n }\n return defaultRouter;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Registers a route that will return a precached file for a navigation\n * request. This is useful for the\n * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.\n *\n * When determining the URL of the precached HTML document, you will likely need\n * to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for\n * the fact that Workbox's precaching naming conventions often results in URL\n * cache keys that contain extra revisioning info.\n *\n * This method will generate a\n * [NavigationRoute]{@link workbox.routing.NavigationRoute}\n * and call\n * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a\n * singleton Router instance.\n *\n * @param {string} cachedAssetUrl The cache key to use for the HTML file.\n * @param {Object} [options]\n * @param {string} [options.cacheName] Cache name to store and retrieve\n * requests. Defaults to precache cache name provided by\n * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.\n * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns\n * match, the route will not handle the request (even if a whitelist entry\n * matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n * @return {workbox.routing.NavigationRoute} Returns the generated\n * Route.\n *\n * @alias workbox.routing.registerNavigationRoute\n */\nexport const registerNavigationRoute = (cachedAssetUrl, options = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cachedAssetUrl, 'string', {\n moduleName: 'workbox-routing',\n funcName: 'registerNavigationRoute',\n paramName: 'cachedAssetUrl',\n });\n }\n\n const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, {cacheName});\n\n if (response) {\n return response;\n }\n\n // This shouldn't normally happen, but there are edge cases:\n // https://github.com/GoogleChrome/workbox/issues/1441\n throw new Error(`The cache ${cacheName} did not have an entry for ` +\n `${cachedAssetUrl}.`);\n } catch (error) {\n // If there's either a cache miss, or the caches.match() call threw\n // an exception, then attempt to fulfill the navigation request with\n // a response from the network rather than leaving the user with a\n // failed navigation.\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Unable to respond to navigation request with ` +\n `cached response. Falling back to network.`, error);\n }\n\n // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {Route} from './Route.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Easily register a RegExp, string, or function with a caching\n * strategy to a singleton Router instance.\n *\n * This method will generate a Route for you if needed and\n * call [Router.registerRoute()]{@link\n * workbox.routing.Router#registerRoute}.\n *\n * @param {\n * RegExp|\n * string|\n * workbox.routing.Route~matchCallback|\n * workbox.routing.Route\n * } capture\n * If the capture param is a `Route`, all other arguments will be ignored.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n * @return {workbox.routing.Route} The generated `Route`(Useful for\n * unregistering).\n *\n * @alias workbox.routing.registerRoute\n */\nexport const registerRoute = (capture, handler, method = 'GET') => {\n let route;\n\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location);\n\n if (process.env.NODE_ENV !== 'production') {\n if (!(capture.startsWith('/') || capture.startsWith('http'))) {\n throw new WorkboxError('invalid-string', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n // We want to check if Express-style wildcards are in the pathname only.\n // TODO: Remove this log message in v4.\n const valueToCheck = capture.startsWith('http') ?\n captureUrl.pathname : capture;\n\n // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(\n `The '$capture' parameter contains an Express-style wildcard ` +\n `character (${wildcards}). Strings are now always interpreted as ` +\n `exact matches; use a RegExp for partial or wildcard matches.`\n );\n }\n }\n\n const matchCallback = ({url}) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(\n `${capture} only partially matches the cross-origin URL ` +\n `${url}. This route will only handle cross-origin requests ` +\n `if they match the entire URL.`);\n }\n }\n\n return url.href === captureUrl.href;\n };\n\n route = new Route(matchCallback, handler, method);\n } else if (capture instanceof RegExp) {\n route = new RegExpRoute(capture, handler, method);\n } else if (typeof capture === 'function') {\n route = new Route(capture, handler, method);\n } else if (capture instanceof Route) {\n route = capture;\n } else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setCatchHandler\n */\nexport const setCatchHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setCatchHandler(handler);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setDefaultHandler\n */\nexport const setDefaultHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setDefaultHandler(handler);\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {registerNavigationRoute} from './registerNavigationRoute.mjs';\nimport {registerRoute} from './registerRoute.mjs';\nimport {Route} from './Route.mjs';\nimport {Router} from './Router.mjs';\nimport {setCatchHandler} from './setCatchHandler.mjs';\nimport {setDefaultHandler} from './setDefaultHandler.mjs';\n\nimport './_version.mjs';\n\nif (process.env.NODE_ENV !== 'production') {\n assert.isSWEnv('workbox-routing');\n}\n\n/**\n * @namespace workbox.routing\n */\n\nexport {\n NavigationRoute,\n RegExpRoute,\n registerNavigationRoute,\n registerRoute,\n Route,\n Router,\n setCatchHandler,\n setDefaultHandler,\n};\n"],"names":["self","_","e","defaultMethod","validMethods","normalizeHandler","handler","assert","hasMethod","moduleName","className","funcName","paramName","isType","handle","Route","constructor","match","method","isOneOf","NavigationRoute","whitelist","blacklist","isArrayOfClass","RegExp","options","_match","_whitelist","_blacklist","url","request","mode","pathnameAndSearch","pathname","search","regExp","test","logger","log","some","debug","RegExpRoute","isInstance","result","exec","href","origin","location","index","slice","Router","_routes","Map","routes","addFetchListener","addEventListener","event","responsePromise","handleRequest","respondWith","addCacheListener","data","type","payload","urlsToCache","requestPromises","Promise","all","map","entry","Request","waitUntil","ports","postMessage","URL","protocol","startsWith","params","route","findMatchingRoute","debugMessages","push","_defaultHandler","getFriendlyURL","groupCollapsed","forEach","msg","Array","isArray","groupEnd","err","reject","_catchHandler","catch","error","get","matchResult","length","Object","keys","setDefaultHandler","setCatchHandler","registerRoute","has","set","unregisterRoute","WorkboxError","routeIndex","indexOf","splice","defaultRouter","getOrCreateDefaultRouter","registerNavigationRoute","cachedAssetUrl","cacheName","cacheNames","getPrecacheName","response","caches","Error","fetch","capture","captureUrl","valueToCheck","wildcards","matchCallback","isSWEnv"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,uBAAD,CAAJ,IAA+BC,CAAC,EAAhC;EAAmC,CAAvC,CAAuC,OAAMC,CAAN,EAAQ;;ECA/C;;;;;;;AAQA,EAEA;;;;;;;;;AAQA,EAAO,MAAMC,aAAa,GAAG,KAAtB;EAEP;;;;;;;;AAOA,EAAO,MAAMC,YAAY,GAAG,CAC1B,QAD0B,EAE1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D;;EAED,QAAMkG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACR,aAAd,CAA4BxB,KAA5B;EAEA,SAAOA,KAAP;EACD,CAhEM;;ECxCP;;;;;;;AAQA,EAIA;;;;;;;;;;AASA,QAAauB,eAAe,GAAI/F,OAAD,IAAa;EAC1C,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACT,eAAd,CAA8B/F,OAA9B;EACD,CAHM;;ECrBP;;;;;;;AAQA,EAIA;;;;;;;;;;;;;AAYA,QAAa8F,iBAAiB,GAAI9F,OAAD,IAAa;EAC5C,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACV,iBAAd,CAAgC9F,OAAhC;EACD,CAHM;;ECxBP;;;;;;;AAQA;AAaA,EAA2C;EACzCC,EAAAA,iBAAM,CAACuH,OAAP,CAAe,iBAAf;EACD;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.routing=function(t,e,r){"use strict";try{self["workbox:routing:4.3.1"]&&_()}catch(t){}const s="GET",n=t=>t&&"object"==typeof t?t:{handle:t};class o{constructor(t,e,r){this.handler=n(e),this.match=t,this.method=r||s}}class i extends o{constructor(t,{whitelist:e=[/./],blacklist:r=[]}={}){super(t=>this.t(t),t),this.s=e,this.o=r}t({url:t,request:e}){if("navigate"!==e.mode)return!1;const r=t.pathname+t.search;for(const t of this.o)if(t.test(r))return!1;return!!this.s.some(t=>t.test(r))}}class u extends o{constructor(t,e,r){super(({url:e})=>{const r=t.exec(e.href);return r?e.origin!==location.origin&&0!==r.index?null:r.slice(1):null},e,r)}}class c{constructor(){this.i=new Map}get routes(){return this.i}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,r=this.handleRequest({request:e,event:t});r&&t.respondWith(r)})}addCacheListener(){self.addEventListener("message",async t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,r=Promise.all(e.urlsToCache.map(t=>{"string"==typeof t&&(t=[t]);const e=new Request(...t);return this.handleRequest({request:e})}));t.waitUntil(r),t.ports&&t.ports[0]&&(await r,t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const r=new URL(t.url,location);if(!r.protocol.startsWith("http"))return;let s,{params:n,route:o}=this.findMatchingRoute({url:r,request:t,event:e}),i=o&&o.handler;if(!i&&this.u&&(i=this.u),i){try{s=i.handle({url:r,request:t,event:e,params:n})}catch(t){s=Promise.reject(t)}return s&&this.h&&(s=s.catch(t=>this.h.handle({url:r,event:e,err:t}))),s}}findMatchingRoute({url:t,request:e,event:r}){const s=this.i.get(e.method)||[];for(const n of s){let s,o=n.match({url:t,request:e,event:r});if(o)return Array.isArray(o)&&o.length>0?s=o:o.constructor===Object&&Object.keys(o).length>0&&(s=o),{route:n,params:s}}return{}}setDefaultHandler(t){this.u=n(t)}setCatchHandler(t){this.h=n(t)}registerRoute(t){this.i.has(t.method)||this.i.set(t.method,[]),this.i.get(t.method).push(t)}unregisterRoute(t){if(!this.i.has(t.method))throw new r.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const e=this.i.get(t.method).indexOf(t);if(!(e>-1))throw new r.WorkboxError("unregister-route-route-not-registered");this.i.get(t.method).splice(e,1)}}let a;const h=()=>(a||((a=new c).addFetchListener(),a.addCacheListener()),a);return t.NavigationRoute=i,t.RegExpRoute=u,t.registerNavigationRoute=((t,r={})=>{const s=e.cacheNames.getPrecacheName(r.cacheName),n=new i(async()=>{try{const e=await caches.match(t,{cacheName:s});if(e)return e;throw new Error(`The cache ${s} did not have an entry for `+`${t}.`)}catch(e){return fetch(t)}},{whitelist:r.whitelist,blacklist:r.blacklist});return h().registerRoute(n),n}),t.registerRoute=((t,e,s="GET")=>{let n;if("string"==typeof t){const r=new URL(t,location);n=new o(({url:t})=>t.href===r.href,e,s)}else if(t instanceof RegExp)n=new u(t,e,s);else if("function"==typeof t)n=new o(t,e,s);else{if(!(t instanceof o))throw new r.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});n=t}return h().registerRoute(n),n}),t.Route=o,t.Router=c,t.setCatchHandler=(t=>{h().setCatchHandler(t)}),t.setDefaultHandler=(t=>{h().setDefaultHandler(t)}),t}({},workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-routing.prod.js.map
{"version":3,"file":"workbox-routing.prod.js","sources":["../_version.mjs","../utils/constants.mjs","../utils/normalizeHandler.mjs","../Route.mjs","../NavigationRoute.mjs","../RegExpRoute.mjs","../Router.mjs","../utils/getOrCreateDefaultRouter.mjs","../registerNavigationRoute.mjs","../registerRoute.mjs","../setCatchHandler.mjs","../setDefaultHandler.mjs"],"sourcesContent":["try{self['workbox:routing:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * The default HTTP method, 'GET', used when there's no specific method\n * configured for a route.\n *\n * @type {string}\n *\n * @private\n */\nexport const defaultMethod = 'GET';\n\n/**\n * The list of valid HTTP methods associated with requests that could be routed.\n *\n * @type {Array<string>}\n *\n * @private\n */\nexport const validMethods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'PATCH',\n 'POST',\n 'PUT',\n];\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n/**\n * @param {function()|Object} handler Either a function, or an object with a\n * 'handle' method.\n * @return {Object} An object with a handle method.\n *\n * @private\n */\nexport const normalizeHandler = (handler) => {\n if (handler && typeof handler === 'object') {\n if (process.env.NODE_ENV !== 'production') {\n assert.hasMethod(handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return handler;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(handler, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return {handle: handler};\n }\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {defaultMethod, validMethods} from './utils/constants.mjs';\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * A `Route` consists of a pair of callback functions, \"match\" and \"handler\".\n * The \"match\" callback determine if a route should be used to \"handle\" a\n * request by returning a non-falsy value if it can. The \"handler\" callback\n * is called when there is a match and should return a Promise that resolves\n * to a `Response`.\n *\n * @memberof workbox.routing\n */\nclass Route {\n /**\n * Constructor for Route class.\n *\n * @param {workbox.routing.Route~matchCallback} match\n * A callback function that determines whether the route matches a given\n * `fetch` event by returning a non-falsy value.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resolving to a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(match, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(match, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'match',\n });\n\n if (method) {\n assert.isOneOf(method, validMethods, {paramName: 'method'});\n }\n }\n\n // These values are referenced directly by Router so cannot be\n // altered by minifification.\n this.handler = normalizeHandler(handler);\n this.match = match;\n this.method = method || defaultMethod;\n }\n}\n\nexport {Route};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * NavigationRoute makes it easy to create a [Route]{@link\n * workbox.routing.Route} that matches for browser\n * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.\n *\n * It will only match incoming Requests whose\n * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}\n * is set to `navigate`.\n *\n * You can optionally only apply this route to a subset of navigation requests\n * by using one or both of the `blacklist` and `whitelist` parameters.\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass NavigationRoute extends Route {\n /**\n * If both `blacklist` and `whiltelist` are provided, the `blacklist` will\n * take precedence and the request will not match this route.\n *\n * The regular expressions in `whitelist` and `blacklist`\n * are matched against the concatenated\n * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}\n * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}\n * portions of the requested URL.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {Object} options\n * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,\n * the route will not handle the request (even if a whitelist RegExp matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n */\n constructor(handler, {whitelist = [/./], blacklist = []} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArrayOfClass(whitelist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.whitelist',\n });\n assert.isArrayOfClass(blacklist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.blacklist',\n });\n }\n\n super((options) => this._match(options), handler);\n\n this._whitelist = whitelist;\n this._blacklist = blacklist;\n }\n\n /**\n * Routes match handler.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request\n * @return {boolean}\n *\n * @private\n */\n _match({url, request}) {\n if (request.mode !== 'navigate') {\n return false;\n }\n\n const pathnameAndSearch = url.pathname + url.search;\n\n for (const regExp of this._blacklist) {\n if (regExp.test(pathnameAndSearch)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the ` +\n `URL matches this blacklist pattern: ${regExp}`);\n }\n return false;\n }\n }\n\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route is being used.`);\n }\n return true;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the URL ` +\n `being navigated to doesn't match the whitelist.`);\n }\n return false;\n }\n}\n\nexport {NavigationRoute};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * RegExpRoute makes it easy to create a regular expression based\n * [Route]{@link workbox.routing.Route}.\n *\n * For same-origin requests the RegExp only needs to match part of the URL. For\n * requests against third-party servers, you must define a RegExp that matches\n * the start of the URL.\n *\n * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass RegExpRoute extends Route {\n /**\n * If the regulard expression contains\n * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},\n * th ecaptured values will be passed to the\n * [handler's]{@link workbox.routing.Route~handlerCallback} `params`\n * argument.\n *\n * @param {RegExp} regExp The regular expression to match against URLs.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(regExp, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(regExp, RegExp, {\n moduleName: 'workbox-routing',\n className: 'RegExpRoute',\n funcName: 'constructor',\n paramName: 'pattern',\n });\n }\n\n const match = ({url}) => {\n const result = regExp.exec(url.href);\n\n // Return null immediately if there's no match.\n if (!result) {\n return null;\n }\n\n // Require that the match start at the first character in the URL string\n // if it's a cross-origin request.\n // See https://github.com/GoogleChrome/workbox/issues/281 for the context\n // behind this behavior.\n if ((url.origin !== location.origin) && (result.index !== 0)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `The regular expression '${regExp}' only partially matched ` +\n `against the cross-origin URL '${url}'. RegExpRoute's will only ` +\n `handle cross-origin requests if they match the entire URL.`\n );\n }\n\n return null;\n }\n\n // If the route matches, but there aren't any capture groups defined, then\n // this will return [], which is truthy and therefore sufficient to\n // indicate a match.\n // If there are capture groups, then it will return their values.\n return result.slice(1);\n };\n\n super(match, handler, method);\n }\n}\n\nexport {RegExpRoute};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\n\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * The Router can be used to process a FetchEvent through one or more\n * [Routes]{@link workbox.routing.Route} responding with a Request if\n * a matching route exists.\n *\n * If no route matches a given a request, the Router will use a \"default\"\n * handler if one is defined.\n *\n * Should the matching Route throw an error, the Router will use a \"catch\"\n * handler if one is defined to gracefully deal with issues and respond with a\n * Request.\n *\n * If a request matches multiple routes, the **earliest** registered route will\n * be used to respond to the request.\n *\n * @memberof workbox.routing\n */\nclass Router {\n /**\n * Initializes a new Router.\n */\n constructor() {\n this._routes = new Map();\n }\n\n /**\n * @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP\n * method name ('GET', etc.) to an array of all the corresponding `Route`\n * instances that are registered.\n */\n get routes() {\n return this._routes;\n }\n\n /**\n * Adds a fetch event listener to respond to events when a route matches\n * the event's request.\n */\n addFetchListener() {\n self.addEventListener('fetch', (event) => {\n const {request} = event;\n const responsePromise = this.handleRequest({request, event});\n if (responsePromise) {\n event.respondWith(responsePromise);\n }\n });\n }\n\n /**\n * Adds a message event listener for URLs to cache from the window.\n * This is useful to cache resources loaded on the page prior to when the\n * service worker started controlling it.\n *\n * The format of the message data sent from the window should be as follows.\n * Where the `urlsToCache` array may consist of URL strings or an array of\n * URL string + `requestInit` object (the same as you'd pass to `fetch()`).\n *\n * ```\n * {\n * type: 'CACHE_URLS',\n * payload: {\n * urlsToCache: [\n * './script1.js',\n * './script2.js',\n * ['./script3.js', {mode: 'no-cors'}],\n * ],\n * },\n * }\n * ```\n */\n addCacheListener() {\n self.addEventListener('message', async (event) => {\n if (event.data && event.data.type === 'CACHE_URLS') {\n const {payload} = event.data;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n\n const request = new Request(...entry);\n return this.handleRequest({request});\n }));\n\n event.waitUntil(requestPromises);\n\n // If a MessageChannel was used, reply to the message on success.\n if (event.ports && event.ports[0]) {\n await requestPromises;\n event.ports[0].postMessage(true);\n }\n }\n });\n }\n\n /**\n * Apply the routing rules to a FetchEvent object to get a Response from an\n * appropriate Route's handler.\n *\n * @param {Object} options\n * @param {Request} options.request The request to handle (this is usually\n * from a fetch event, but it does not have to be).\n * @param {FetchEvent} [options.event] The event that triggered the request,\n * if applicable.\n * @return {Promise<Response>|undefined} A promise is returned if a\n * registered route can handle the request. If there is no matching\n * route and there's no `defaultHandler`, `undefined` is returned.\n */\n handleRequest({request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'handleRequest',\n paramName: 'options.request',\n });\n }\n\n const url = new URL(request.url, location);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n\n let {params, route} = this.findMatchingRoute({url, request, event});\n let handler = route && route.handler;\n\n let debugMessages = [];\n if (process.env.NODE_ENV !== 'production') {\n if (handler) {\n debugMessages.push([\n `Found a route to handle this request:`, route,\n ]);\n\n if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\n ]);\n }\n }\n }\n\n // If we don't have a handler because there was no matching route, then\n // fall back to defaultHandler if that's defined.\n if (!handler && this._defaultHandler) {\n if (process.env.NODE_ENV !== 'production') {\n debugMessages.push(`Failed to find a matching route. Falling ` +\n `back to the default handler.`);\n\n // This is used for debugging in logs in the case of an error.\n route = '[Default Handler]';\n }\n handler = this._defaultHandler;\n }\n\n if (!handler) {\n if (process.env.NODE_ENV !== 'production') {\n // No handler so Workbox will do nothing. If logs is set of debug\n // i.e. verbose, we should print out this information.\n logger.debug(`No route found for: ${getFriendlyURL(url)}`);\n }\n return;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // We have a handler, meaning Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Router is responding to: ${getFriendlyURL(url)}`);\n debugMessages.forEach((msg) => {\n if (Array.isArray(msg)) {\n logger.log(...msg);\n } else {\n logger.log(msg);\n }\n });\n\n // The Request and Response objects contains a great deal of information,\n // hide it under a group in case developers want to see it.\n logger.groupCollapsed(`View request details here.`);\n logger.log(request);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n\n // Wrap in try and catch in case the handle method throws a synchronous\n // error. It should still callback to the catch handler.\n let responsePromise;\n try {\n responsePromise = handler.handle({url, request, event, params});\n } catch (err) {\n responsePromise = Promise.reject(err);\n }\n\n if (responsePromise && this._catchHandler) {\n responsePromise = responsePromise.catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // Still include URL here as it will be async from the console group\n // and may not make sense without the URL\n logger.groupCollapsed(`Error thrown when responding to: ` +\n ` ${getFriendlyURL(url)}. Falling back to Catch Handler.`);\n logger.error(`Error thrown by:`, route);\n logger.error(err);\n logger.groupEnd();\n }\n return this._catchHandler.handle({url, event, err});\n });\n }\n\n return responsePromise;\n }\n\n /**\n * Checks a request and URL (and optionally an event) against the list of\n * registered routes, and if there's a match, returns the corresponding\n * route along with any params generated by the match.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request The request to match.\n * @param {FetchEvent} [options.event] The corresponding event (unless N/A).\n * @return {Object} An object with `route` and `params` properties.\n * They are populated if a matching route was found or `undefined`\n * otherwise.\n */\n findMatchingRoute({url, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(url, URL, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.url',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.request',\n });\n }\n\n const routes = this._routes.get(request.method) || [];\n for (const route of routes) {\n let params;\n let matchResult = route.match({url, request, event});\n if (matchResult) {\n if (Array.isArray(matchResult) && matchResult.length > 0) {\n // Instead of passing an empty array in as params, use undefined.\n params = matchResult;\n } else if ((matchResult.constructor === Object &&\n Object.keys(matchResult).length > 0)) {\n // Instead of passing an empty object in as params, use undefined.\n params = matchResult;\n }\n\n // Return early if have a match.\n return {route, params};\n }\n }\n // If no match was found above, return and empty object.\n return {};\n }\n\n /**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setDefaultHandler(handler) {\n this._defaultHandler = normalizeHandler(handler);\n }\n\n /**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setCatchHandler(handler) {\n this._catchHandler = normalizeHandler(handler);\n }\n\n /**\n * Registers a route with the router.\n *\n * @param {workbox.routing.Route} route The route to register.\n */\n registerRoute(route) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(route, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\n }\n\n // Give precedence to all of the earlier routes by adding this additional\n // route to the end of the array.\n this._routes.get(route.method).push(route);\n }\n\n /**\n * Unregisters a route with the router.\n *\n * @param {workbox.routing.Route} route The route to unregister.\n */\n unregisterRoute(route) {\n if (!this._routes.has(route.method)) {\n throw new WorkboxError(\n 'unregister-route-but-not-found-with-method', {\n method: route.method,\n }\n );\n }\n\n const routeIndex = this._routes.get(route.method).indexOf(route);\n if (routeIndex > -1) {\n this._routes.get(route.method).splice(routeIndex, 1);\n } else {\n throw new WorkboxError('unregister-route-route-not-registered');\n }\n }\n}\n\nexport {Router};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Router} from '../Router.mjs';\nimport '../_version.mjs';\n\nlet defaultRouter;\n\n/**\n * Creates a new, singleton Router instance if one does not exist. If one\n * does already exist, that instance is returned.\n *\n * @private\n * @return {Router}\n */\nexport const getOrCreateDefaultRouter = () => {\n if (!defaultRouter) {\n defaultRouter = new Router();\n\n // The helpers that use the default Router assume these listeners exist.\n defaultRouter.addFetchListener();\n defaultRouter.addCacheListener();\n }\n return defaultRouter;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Registers a route that will return a precached file for a navigation\n * request. This is useful for the\n * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.\n *\n * When determining the URL of the precached HTML document, you will likely need\n * to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for\n * the fact that Workbox's precaching naming conventions often results in URL\n * cache keys that contain extra revisioning info.\n *\n * This method will generate a\n * [NavigationRoute]{@link workbox.routing.NavigationRoute}\n * and call\n * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a\n * singleton Router instance.\n *\n * @param {string} cachedAssetUrl The cache key to use for the HTML file.\n * @param {Object} [options]\n * @param {string} [options.cacheName] Cache name to store and retrieve\n * requests. Defaults to precache cache name provided by\n * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.\n * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns\n * match, the route will not handle the request (even if a whitelist entry\n * matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n * @return {workbox.routing.NavigationRoute} Returns the generated\n * Route.\n *\n * @alias workbox.routing.registerNavigationRoute\n */\nexport const registerNavigationRoute = (cachedAssetUrl, options = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cachedAssetUrl, 'string', {\n moduleName: 'workbox-routing',\n funcName: 'registerNavigationRoute',\n paramName: 'cachedAssetUrl',\n });\n }\n\n const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, {cacheName});\n\n if (response) {\n return response;\n }\n\n // This shouldn't normally happen, but there are edge cases:\n // https://github.com/GoogleChrome/workbox/issues/1441\n throw new Error(`The cache ${cacheName} did not have an entry for ` +\n `${cachedAssetUrl}.`);\n } catch (error) {\n // If there's either a cache miss, or the caches.match() call threw\n // an exception, then attempt to fulfill the navigation request with\n // a response from the network rather than leaving the user with a\n // failed navigation.\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Unable to respond to navigation request with ` +\n `cached response. Falling back to network.`, error);\n }\n\n // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {Route} from './Route.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Easily register a RegExp, string, or function with a caching\n * strategy to a singleton Router instance.\n *\n * This method will generate a Route for you if needed and\n * call [Router.registerRoute()]{@link\n * workbox.routing.Router#registerRoute}.\n *\n * @param {\n * RegExp|\n * string|\n * workbox.routing.Route~matchCallback|\n * workbox.routing.Route\n * } capture\n * If the capture param is a `Route`, all other arguments will be ignored.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n * @return {workbox.routing.Route} The generated `Route`(Useful for\n * unregistering).\n *\n * @alias workbox.routing.registerRoute\n */\nexport const registerRoute = (capture, handler, method = 'GET') => {\n let route;\n\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location);\n\n if (process.env.NODE_ENV !== 'production') {\n if (!(capture.startsWith('/') || capture.startsWith('http'))) {\n throw new WorkboxError('invalid-string', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n // We want to check if Express-style wildcards are in the pathname only.\n // TODO: Remove this log message in v4.\n const valueToCheck = capture.startsWith('http') ?\n captureUrl.pathname : capture;\n\n // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(\n `The '$capture' parameter contains an Express-style wildcard ` +\n `character (${wildcards}). Strings are now always interpreted as ` +\n `exact matches; use a RegExp for partial or wildcard matches.`\n );\n }\n }\n\n const matchCallback = ({url}) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(\n `${capture} only partially matches the cross-origin URL ` +\n `${url}. This route will only handle cross-origin requests ` +\n `if they match the entire URL.`);\n }\n }\n\n return url.href === captureUrl.href;\n };\n\n route = new Route(matchCallback, handler, method);\n } else if (capture instanceof RegExp) {\n route = new RegExpRoute(capture, handler, method);\n } else if (typeof capture === 'function') {\n route = new Route(capture, handler, method);\n } else if (capture instanceof Route) {\n route = capture;\n } else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setCatchHandler\n */\nexport const setCatchHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setCatchHandler(handler);\n};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setDefaultHandler\n */\nexport const setDefaultHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setDefaultHandler(handler);\n};\n"],"names":["self","_","e","defaultMethod","normalizeHandler","handler","handle","Route","constructor","match","method","NavigationRoute","whitelist","blacklist","options","this","_match","_whitelist","_blacklist","url","request","mode","pathnameAndSearch","pathname","search","regExp","test","some","RegExpRoute","result","exec","href","origin","location","index","slice","Router","_routes","Map","addFetchListener","addEventListener","event","responsePromise","handleRequest","respondWith","addCacheListener","async","data","type","payload","requestPromises","Promise","all","urlsToCache","map","entry","Request","waitUntil","ports","postMessage","URL","protocol","startsWith","params","route","findMatchingRoute","_defaultHandler","err","reject","_catchHandler","catch","routes","get","matchResult","Array","isArray","length","Object","keys","setDefaultHandler","setCatchHandler","registerRoute","has","set","push","unregisterRoute","WorkboxError","routeIndex","indexOf","splice","defaultRouter","getOrCreateDefaultRouter","cachedAssetUrl","cacheName","cacheNames","getPrecacheName","response","caches","Error","error","fetch","capture","captureUrl","RegExp","moduleName","funcName","paramName"],"mappings":"gFAAA,IAAIA,KAAK,0BAA0BC,IAAI,MAAMC,ICkBtC,MAAMC,EAAgB,MCAhBC,EAAoBC,GAC3BA,GAA8B,iBAAZA,EASbA,EAUA,CAACC,OAAQD,GCfpB,MAAME,EAYJC,YAAYC,EAAOJ,EAASK,QAgBrBL,QAAUD,EAAiBC,QAC3BI,MAAQA,OACRC,OAASA,GAAUP,GCzB5B,MAAMQ,UAAwBJ,EAoB5BC,YAAYH,GAASO,UAACA,EAAY,CAAC,KAAdC,UAAoBA,EAAY,IAAM,UAgBlDC,GAAYC,KAAKC,EAAOF,GAAUT,QAEpCY,EAAaL,OACbM,EAAaL,EAapBG,GAAOG,IAACA,EAADC,QAAMA,OACU,aAAjBA,EAAQC,YACH,QAGHC,EAAoBH,EAAII,SAAWJ,EAAIK,WAExC,MAAMC,KAAUV,KAAKG,KACpBO,EAAOC,KAAKJ,UAKP,UAIPP,KAAKE,EAAWU,KAAMF,GAAWA,EAAOC,KAAKJ,KCvErD,MAAMM,UAAoBrB,EAcxBC,YAAYiB,EAAQpB,EAASK,SAUb,EAAES,IAAAA,YACRU,EAASJ,EAAOK,KAAKX,EAAIY,aAG1BF,EAQAV,EAAIa,SAAWC,SAASD,QAA6B,IAAjBH,EAAOK,MASvC,KAOFL,EAAOM,MAAM,GAvBX,MA0BE9B,EAASK,IChD1B,MAAM0B,EAIJ5B,mBACO6B,EAAU,IAAIC,wBASZvB,KAAKsB,EAOdE,mBACEvC,KAAKwC,iBAAiB,QAAUC,UACxBrB,QAACA,GAAWqB,EACZC,EAAkB3B,KAAK4B,cAAc,CAACvB,QAAAA,EAASqB,MAAAA,IACjDC,GACFD,EAAMG,YAAYF,KA2BxBG,mBAC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AAIY,OAASuE,EAAWvE,KAGA1B,EAASK,QACrC,GAAI2F,aAAmBE,OAC5BvC,EAAQ,IAAIpC,EAAYyE,EAAShG,EAASK,QACrC,GAAuB,mBAAZ2F,EAChBrC,EAAQ,IAAIzD,EAAM8F,EAAShG,EAASK,OAC/B,CAAA,KAAI2F,aAAmB9F,SAGtB,IAAI+E,eAAa,yBAA0B,CAC/CkB,WAAY,kBACZC,SAAU,gBACVC,UAAW,YALb1C,EAAQqC,SASYV,IACRV,cAAcjB,GAErBA,2CClFuB3D,CAAAA,IACRsF,IACRX,gBAAgB3E,yBCCEA,CAAAA,IACVsF,IACRZ,kBAAkB1E"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.strategies = (function (exports, logger_mjs, assert_mjs, cacheNames_mjs, cacheWrapper_mjs, fetchWrapper_mjs, getFriendlyURL_mjs, WorkboxError_mjs) {
'use strict';
try {
self['workbox:strategies:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const getFriendlyURL = url => {
const urlObj = new URL(url, location);
if (urlObj.origin === location.origin) {
return urlObj.pathname;
}
return urlObj.href;
};
const messages = {
strategyStart: (strategyName, request) => `Using ${strategyName} to ` + `respond to '${getFriendlyURL(request.url)}'`,
printFinalResponse: response => {
if (response) {
logger_mjs.logger.groupCollapsed(`View the final response here.`);
logger_mjs.logger.log(response);
logger_mjs.logger.groupEnd();
}
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}
* request strategy.
*
* A cache first strategy is useful for assets that have been revisioned,
* such as URLs like `/styles/example.a8f5f1.css`, since they
* can be cached for long periods of time.
*
* If the network request fails, and there is no cache match, this will throw
* a `WorkboxError` exception.
*
* @memberof workbox.strategies
*/
class CacheFirst {
/**
* @param {Object} options
* @param {string} options.cacheName Cache name to store and retrieve
* requests. Defaults to cache names provided by
* [workbox-core]{@link workbox.core.cacheNames}.
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.
* @param {Object} options.fetchOptions Values passed along to the
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
* of all fetch() requests made by this strategy.
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
*/
constructor(options = {}) {
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
this._plugins = options.plugins || [];
this._fetchOptions = options.fetchOptions || null;
this._matchOptions = options.matchOptions || null;
}
/**
* This method will perform a request strategy and follows an API that
* will work with the
* [Workbox Router]{@link workbox.routing.Router}.
*
* @param {Object} options
* @param {Request} options.request The request to run this strategy for.
* @param {Event} [options.event] The event that triggered the request.
* @return {Promise<Response>}
*/
async handle({
event,
request
}) {
return this.makeRequest({
event,
request: request || event.request
});
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} options
* @param {Request|string} options.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
be called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
async makeRequest({
event,
request
}) {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'CacheFirst',
funcName: 'makeRequest',
paramName: 'request'
});
}
let response = await cacheWrapper_mjs.cacheWrapper.match({
cacheName: this._cacheName,
request,
event,
matchOptions: this._matchOptions,
plugins: this._plugins
});
let error;
if (!response) {
{
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will respond with a network request.`);
}
try {
response = await this._getFromNetwork(request, event);
} catch (err) {
error = err;
}
{
if (response) {
logs.push(`Got response from network.`);
} else {
logs.push(`Unable to get a response from the network.`);
}
}
} else {
{
logs.push(`Found a cached response in the '${this._cacheName}' cache.`);
}
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheFirst', request));
for (let log of logs) {
logger_mjs.logger.log(log);
}
messages.printFinalResponse(response);
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url,
error
});
}
return response;
}
/**
* Handles the network and cache part of CacheFirst.
*
* @param {Request} request
* @param {FetchEvent} [event]
* @return {Promise<Response>}
*
* @private
*/
async _getFromNetwork(request, event) {
const response = await fetchWrapper_mjs.fetchWrapper.fetch({
request,
event,
fetchOptions: this._fetchOptions,
plugins: this._plugins
}); // Keep the service worker while we put the request to the cache
const responseClone = response.clone();
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put({
cacheName: this._cacheName,
request,
response: responseClone,
event,
plugins: this._plugins
});
if (event) {
try {
event.waitUntil(cachePutPromise);
} catch (error) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
}
}
}
return response;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* An implementation of a
* [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}
* request strategy.
*
* This class is useful if you want to take advantage of any
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
*
* If there is no cache match, this will throw a `WorkboxError` exception.
*
* @memberof workbox.strategies
*/
class CacheOnly {
/**
* @param {Object} options
* @param {string} options.cacheName Cache name to store and retrieve
* requests. Defaults to cache names provided by
* [workbox-core]{@link workbox.core.cacheNames}.
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
*/
constructor(options = {}) {
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
this._plugins = options.plugins || [];
this._matchOptions = options.matchOptions || null;
}
/**
* This method will perform a request strategy and follows an API that
* will work with the
* [Workbox Router]{@link workbox.routing.Router}.
*
* @param {Object} options
* @param {Request} options.request The request to run this strategy for.
* @param {Event} [options.event] The event that triggered the request.
* @return {Promise<Response>}
*/
async handle({
event,
request
}) {
return this.makeRequest({
event,
request: request || event.request
});
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} options
* @param {Request|string} options.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
* be called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
async makeRequest({
event,
request
}) {
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'CacheOnly',
funcName: 'makeRequest',
paramName: 'request'
});
}
const response = await cacheWrapper_mjs.cacheWrapper.match({
cacheName: this._cacheName,
request,
event,
matchOptions: this._matchOptions,
plugins: this._plugins
});
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheOnly', request));
if (response) {
logger_mjs.logger.log(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
messages.printFinalResponse(response);
} else {
logger_mjs.logger.log(`No response found in the '${this._cacheName}' cache.`);
}
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url
});
}
return response;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const cacheOkAndOpaquePlugin = {
/**
* Returns a valid response (to allow caching) if the status is 200 (OK) or
* 0 (opaque).
*
* @param {Object} options
* @param {Response} options.response
* @return {Response|null}
*
* @private
*/
cacheWillUpdate: ({
response
}) => {
if (response.status === 200 || response.status === 0) {
return response;
}
return null;
}
};
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* An implementation of a
* [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}
* request strategy.
*
* By default, this strategy will cache responses with a 200 status code as
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
* Opaque responses are are cross-origin requests where the response doesn't
* support [CORS]{@link https://enable-cors.org/}.
*
* If the network request fails, and there is no cache match, this will throw
* a `WorkboxError` exception.
*
* @memberof workbox.strategies
*/
class NetworkFirst {
/**
* @param {Object} options
* @param {string} options.cacheName Cache name to store and retrieve
* requests. Defaults to cache names provided by
* [workbox-core]{@link workbox.core.cacheNames}.
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.
* @param {Object} options.fetchOptions Values passed along to the
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
* of all fetch() requests made by this strategy.
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
* @param {number} options.networkTimeoutSeconds If set, any network requests
* that fail to respond within the timeout will fallback to the cache.
*
* This option can be used to combat
* "[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}"
* scenarios.
*/
constructor(options = {}) {
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
if (options.plugins) {
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
} else {
// No plugins passed in, use the default plugin.
this._plugins = [cacheOkAndOpaquePlugin];
}
this._networkTimeoutSeconds = options.networkTimeoutSeconds;
{
if (this._networkTimeoutSeconds) {
assert_mjs.assert.isType(this._networkTimeoutSeconds, 'number', {
moduleName: 'workbox-strategies',
className: 'NetworkFirst',
funcName: 'constructor',
paramName: 'networkTimeoutSeconds'
});
}
}
this._fetchOptions = options.fetchOptions || null;
this._matchOptions = options.matchOptions || null;
}
/**
* This method will perform a request strategy and follows an API that
* will work with the
* [Workbox Router]{@link workbox.routing.Router}.
*
* @param {Object} options
* @param {Request} options.request The request to run this strategy for.
* @param {Event} [options.event] The event that triggered the request.
* @return {Promise<Response>}
*/
async handle({
event,
request
}) {
return this.makeRequest({
event,
request: request || event.request
});
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} options
* @param {Request|string} options.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
* be called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
async makeRequest({
event,
request
}) {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'NetworkFirst',
funcName: 'handle',
paramName: 'makeRequest'
});
}
const promises = [];
let timeoutId;
if (this._networkTimeoutSeconds) {
const {
id,
promise
} = this._getTimeoutPromise({
request,
event,
logs
});
timeoutId = id;
promises.push(promise);
}
const networkPromise = this._getNetworkPromise({
timeoutId,
request,
event,
logs
});
promises.push(networkPromise); // Promise.race() will resolve as soon as the first promise resolves.
let response = await Promise.race(promises); // If Promise.race() resolved with null, it might be due to a network
// timeout + a cache miss. If that were to happen, we'd rather wait until
// the networkPromise resolves instead of returning null.
// Note that it's fine to await an already-resolved promise, so we don't
// have to check to see if it's still "in flight".
if (!response) {
response = await networkPromise;
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));
for (let log of logs) {
logger_mjs.logger.log(log);
}
messages.printFinalResponse(response);
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url
});
}
return response;
}
/**
* @param {Object} options
* @param {Request} options.request
* @param {Array} options.logs A reference to the logs array
* @param {Event} [options.event]
* @return {Promise<Response>}
*
* @private
*/
_getTimeoutPromise({
request,
logs,
event
}) {
let timeoutId;
const timeoutPromise = new Promise(resolve => {
const onNetworkTimeout = async () => {
{
logs.push(`Timing out the network response at ` + `${this._networkTimeoutSeconds} seconds.`);
}
resolve((await this._respondFromCache({
request,
event
})));
};
timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000);
});
return {
promise: timeoutPromise,
id: timeoutId
};
}
/**
* @param {Object} options
* @param {number|undefined} options.timeoutId
* @param {Request} options.request
* @param {Array} options.logs A reference to the logs Array.
* @param {Event} [options.event]
* @return {Promise<Response>}
*
* @private
*/
async _getNetworkPromise({
timeoutId,
request,
logs,
event
}) {
let error;
let response;
try {
response = await fetchWrapper_mjs.fetchWrapper.fetch({
request,
event,
fetchOptions: this._fetchOptions,
plugins: this._plugins
});
} catch (err) {
error = err;
}
if (timeoutId) {
clearTimeout(timeoutId);
}
{
if (response) {
logs.push(`Got response from network.`);
} else {
logs.push(`Unable to get a response from the network. Will respond ` + `with a cached response.`);
}
}
if (error || !response) {
response = await this._respondFromCache({
request,
event
});
{
if (response) {
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
} else {
logs.push(`No response found in the '${this._cacheName}' cache.`);
}
}
} else {
// Keep the service worker alive while we put the request in the cache
const responseClone = response.clone();
const cachePut = cacheWrapper_mjs.cacheWrapper.put({
cacheName: this._cacheName,
request,
response: responseClone,
event,
plugins: this._plugins
});
if (event) {
try {
// The event has been responded to so we can keep the SW alive to
// respond to the request
event.waitUntil(cachePut);
} catch (err) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
}
}
}
}
return response;
}
/**
* Used if the network timeouts or fails to make the request.
*
* @param {Object} options
* @param {Request} request The request to match in the cache
* @param {Event} [options.event]
* @return {Promise<Object>}
*
* @private
*/
_respondFromCache({
event,
request
}) {
return cacheWrapper_mjs.cacheWrapper.match({
cacheName: this._cacheName,
request,
event,
matchOptions: this._matchOptions,
plugins: this._plugins
});
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* An implementation of a
* [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}
* request strategy.
*
* This class is useful if you want to take advantage of any
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
*
* If the network request fails, this will throw a `WorkboxError` exception.
*
* @memberof workbox.strategies
*/
class NetworkOnly {
/**
* @param {Object} options
* @param {string} options.cacheName Cache name to store and retrieve
* requests. Defaults to cache names provided by
* [workbox-core]{@link workbox.core.cacheNames}.
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.
* @param {Object} options.fetchOptions Values passed along to the
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
* of all fetch() requests made by this strategy.
*/
constructor(options = {}) {
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
this._plugins = options.plugins || [];
this._fetchOptions = options.fetchOptions || null;
}
/**
* This method will perform a request strategy and follows an API that
* will work with the
* [Workbox Router]{@link workbox.routing.Router}.
*
* @param {Object} options
* @param {Request} options.request The request to run this strategy for.
* @param {Event} [options.event] The event that triggered the request.
* @return {Promise<Response>}
*/
async handle({
event,
request
}) {
return this.makeRequest({
event,
request: request || event.request
});
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} options
* @param {Request|string} options.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
* be called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
async makeRequest({
event,
request
}) {
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'NetworkOnly',
funcName: 'handle',
paramName: 'request'
});
}
let error;
let response;
try {
response = await fetchWrapper_mjs.fetchWrapper.fetch({
request,
event,
fetchOptions: this._fetchOptions,
plugins: this._plugins
});
} catch (err) {
error = err;
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));
if (response) {
logger_mjs.logger.log(`Got response from network.`);
} else {
logger_mjs.logger.log(`Unable to get a response from the network.`);
}
messages.printFinalResponse(response);
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url,
error
});
}
return response;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* An implementation of a
* [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}
* request strategy.
*
* Resources are requested from both the cache and the network in parallel.
* The strategy will respond with the cached version if available, otherwise
* wait for the network response. The cache is updated with the network response
* with each successful request.
*
* By default, this strategy will cache responses with a 200 status code as
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
* Opaque responses are are cross-origin requests where the response doesn't
* support [CORS]{@link https://enable-cors.org/}.
*
* If the network request fails, and there is no cache match, this will throw
* a `WorkboxError` exception.
*
* @memberof workbox.strategies
*/
class StaleWhileRevalidate {
/**
* @param {Object} options
* @param {string} options.cacheName Cache name to store and retrieve
* requests. Defaults to cache names provided by
* [workbox-core]{@link workbox.core.cacheNames}.
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
* to use in conjunction with this caching strategy.
* @param {Object} options.fetchOptions Values passed along to the
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
* of all fetch() requests made by this strategy.
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
*/
constructor(options = {}) {
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
this._plugins = options.plugins || [];
if (options.plugins) {
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
} else {
// No plugins passed in, use the default plugin.
this._plugins = [cacheOkAndOpaquePlugin];
}
this._fetchOptions = options.fetchOptions || null;
this._matchOptions = options.matchOptions || null;
}
/**
* This method will perform a request strategy and follows an API that
* will work with the
* [Workbox Router]{@link workbox.routing.Router}.
*
* @param {Object} options
* @param {Request} options.request The request to run this strategy for.
* @param {Event} [options.event] The event that triggered the request.
* @return {Promise<Response>}
*/
async handle({
event,
request
}) {
return this.makeRequest({
event,
request: request || event.request
});
}
/**
* This method can be used to perform a make a standalone request outside the
* context of the [Workbox Router]{@link workbox.routing.Router}.
*
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
* for more usage information.
*
* @param {Object} options
* @param {Request|string} options.request Either a
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
* object, or a string URL, corresponding to the request to be made.
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
* be called automatically to extend the service worker's lifetime.
* @return {Promise<Response>}
*/
async makeRequest({
event,
request
}) {
const logs = [];
if (typeof request === 'string') {
request = new Request(request);
}
{
assert_mjs.assert.isInstance(request, Request, {
moduleName: 'workbox-strategies',
className: 'StaleWhileRevalidate',
funcName: 'handle',
paramName: 'request'
});
}
const fetchAndCachePromise = this._getFromNetwork({
request,
event
});
let response = await cacheWrapper_mjs.cacheWrapper.match({
cacheName: this._cacheName,
request,
event,
matchOptions: this._matchOptions,
plugins: this._plugins
});
let error;
if (response) {
{
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache. Will update with the network response in the background.`);
}
if (event) {
try {
event.waitUntil(fetchAndCachePromise);
} catch (error) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
}
}
}
} else {
{
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will wait for the network response.`);
}
try {
response = await fetchAndCachePromise;
} catch (err) {
error = err;
}
}
{
logger_mjs.logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));
for (let log of logs) {
logger_mjs.logger.log(log);
}
messages.printFinalResponse(response);
logger_mjs.logger.groupEnd();
}
if (!response) {
throw new WorkboxError_mjs.WorkboxError('no-response', {
url: request.url,
error
});
}
return response;
}
/**
* @param {Object} options
* @param {Request} options.request
* @param {Event} [options.event]
* @return {Promise<Response>}
*
* @private
*/
async _getFromNetwork({
request,
event
}) {
const response = await fetchWrapper_mjs.fetchWrapper.fetch({
request,
event,
fetchOptions: this._fetchOptions,
plugins: this._plugins
});
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put({
cacheName: this._cacheName,
request,
response: response.clone(),
event,
plugins: this._plugins
});
if (event) {
try {
event.waitUntil(cachePutPromise);
} catch (error) {
{
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
}
}
}
return response;
}
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const mapping = {
cacheFirst: CacheFirst,
cacheOnly: CacheOnly,
networkFirst: NetworkFirst,
networkOnly: NetworkOnly,
staleWhileRevalidate: StaleWhileRevalidate
};
const deprecate = strategy => {
const StrategyCtr = mapping[strategy];
return options => {
{
const strategyCtrName = strategy[0].toUpperCase() + strategy.slice(1);
logger_mjs.logger.warn(`The 'workbox.strategies.${strategy}()' function has been ` + `deprecated and will be removed in a future version of Workbox.\n` + `Please use 'new workbox.strategies.${strategyCtrName}()' instead.`);
}
return new StrategyCtr(options);
};
};
/**
* @function workbox.strategies.cacheFirst
* @param {Object} options See the {@link workbox.strategies.CacheFirst}
* constructor for more info.
* @deprecated since v4.0.0
*/
const cacheFirst = deprecate('cacheFirst');
/**
* @function workbox.strategies.cacheOnly
* @param {Object} options See the {@link workbox.strategies.CacheOnly}
* constructor for more info.
* @deprecated since v4.0.0
*/
const cacheOnly = deprecate('cacheOnly');
/**
* @function workbox.strategies.networkFirst
* @param {Object} options See the {@link workbox.strategies.NetworkFirst}
* constructor for more info.
* @deprecated since v4.0.0
*/
const networkFirst = deprecate('networkFirst');
/**
* @function workbox.strategies.networkOnly
* @param {Object} options See the {@link workbox.strategies.NetworkOnly}
* constructor for more info.
* @deprecated since v4.0.0
*/
const networkOnly = deprecate('networkOnly');
/**
* @function workbox.strategies.staleWhileRevalidate
* @param {Object} options See the
* {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.
* @deprecated since v4.0.0
*/
const staleWhileRevalidate = deprecate('staleWhileRevalidate');
exports.CacheFirst = CacheFirst;
exports.CacheOnly = CacheOnly;
exports.NetworkFirst = NetworkFirst;
exports.NetworkOnly = NetworkOnly;
exports.StaleWhileRevalidate = StaleWhileRevalidate;
exports.cacheFirst = cacheFirst;
exports.cacheOnly = cacheOnly;
exports.networkFirst = networkFirst;
exports.networkOnly = networkOnly;
exports.staleWhileRevalidate = staleWhileRevalidate;
return exports;
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-strategies.dev.js.map
{"version":3,"file":"workbox-strategies.dev.js","sources":["../_version.mjs","../utils/messages.mjs","../CacheFirst.mjs","../CacheOnly.mjs","../plugins/cacheOkAndOpaquePlugin.mjs","../NetworkFirst.mjs","../NetworkOnly.mjs","../StaleWhileRevalidate.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:strategies:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport '../_version.mjs';\n\nconst getFriendlyURL = (url) => {\n const urlObj = new URL(url, location);\n if (urlObj.origin === location.origin) {\n return urlObj.pathname;\n }\n return urlObj.href;\n};\n\nexport const messages = {\n strategyStart: (strategyName, request) => `Using ${strategyName} to ` +\n `respond to '${getFriendlyURL(request.url)}'`,\n printFinalResponse: (response) => {\n if (response) {\n logger.groupCollapsed(`View the final response here.`);\n logger.log(response);\n logger.groupEnd();\n }\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}\n * request strategy.\n *\n * A cache first strategy is useful for assets that have been revisioned,\n * such as URLs like `/styles/example.a8f5f1.css`, since they\n * can be cached for long periods of time.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass CacheFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheFirst',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n\n let error;\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(\n `No response found in the '${this._cacheName}' cache. ` +\n `Will respond with a network request.`);\n }\n try {\n response = await this._getFromNetwork(request, event);\n } catch (err) {\n error = err;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n } else {\n logs.push(`Unable to get a response from the network.`);\n }\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(\n `Found a cached response in the '${this._cacheName}' cache.`);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('CacheFirst', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n\n /**\n * Handles the network and cache part of CacheFirst.\n *\n * @param {Request} request\n * @param {FetchEvent} [event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork(request, event) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n\n // Keep the service worker while we put the request to the cache\n const responseClone = response.clone();\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n\n return response;\n }\n}\n\nexport {CacheFirst};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n\n/**\n * An implementation of a\n * [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If there is no cache match, this will throw a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass CacheOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheOnly',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n\n const response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('CacheOnly', request));\n if (response) {\n logger.log(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n messages.printFinalResponse(response);\n } else {\n logger.log(`No response found in the '${this._cacheName}' cache.`);\n }\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url});\n }\n return response;\n }\n}\n\nexport {CacheOnly};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const cacheOkAndOpaquePlugin = {\n /**\n * Returns a valid response (to allow caching) if the status is 200 (OK) or\n * 0 (opaque).\n *\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n *\n * @private\n */\n cacheWillUpdate: ({response}) => {\n if (response.status === 200 || response.status === 0) {\n return response;\n }\n return null;\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport {cacheOkAndOpaquePlugin} from './plugins/cacheOkAndOpaquePlugin.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}\n * request strategy.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass NetworkFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n * @param {number} options.networkTimeoutSeconds If set, any network requests\n * that fail to respond within the timeout will fallback to the cache.\n *\n * This option can be used to combat\n * \"[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}\"\n * scenarios.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n\n if (options.plugins) {\n let isUsingCacheWillUpdate =\n options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n } else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n\n this._networkTimeoutSeconds = options.networkTimeoutSeconds;\n if (process.env.NODE_ENV !== 'production') {\n if (this._networkTimeoutSeconds) {\n assert.isType(this._networkTimeoutSeconds, 'number', {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'constructor',\n paramName: 'networkTimeoutSeconds',\n });\n }\n }\n\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'handle',\n paramName: 'makeRequest',\n });\n }\n\n const promises = [];\n let timeoutId;\n\n if (this._networkTimeoutSeconds) {\n const {id, promise} = this._getTimeoutPromise({request, event, logs});\n timeoutId = id;\n promises.push(promise);\n }\n\n const networkPromise =\n this._getNetworkPromise({timeoutId, request, event, logs});\n promises.push(networkPromise);\n\n // Promise.race() will resolve as soon as the first promise resolves.\n let response = await Promise.race(promises);\n // If Promise.race() resolved with null, it might be due to a network\n // timeout + a cache miss. If that were to happen, we'd rather wait until\n // the networkPromise resolves instead of returning null.\n // Note that it's fine to await an already-resolved promise, so we don't\n // have to check to see if it's still \"in flight\".\n if (!response) {\n response = await networkPromise;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('NetworkFirst', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url});\n }\n return response;\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs array\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n _getTimeoutPromise({request, logs, event}) {\n let timeoutId;\n const timeoutPromise = new Promise((resolve) => {\n const onNetworkTimeout = async () => {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Timing out the network response at ` +\n `${this._networkTimeoutSeconds} seconds.`);\n }\n\n resolve(await this._respondFromCache({request, event}));\n };\n\n timeoutId = setTimeout(\n onNetworkTimeout,\n this._networkTimeoutSeconds * 1000,\n );\n });\n\n return {\n promise: timeoutPromise,\n id: timeoutId,\n };\n }\n\n /**\n * @param {Object} options\n * @param {number|undefined} options.timeoutId\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs Array.\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getNetworkPromise({timeoutId, request, logs, event}) {\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n } catch (err) {\n error = err;\n }\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n } else {\n logs.push(`Unable to get a response from the network. Will respond ` +\n `with a cached response.`);\n }\n }\n\n if (error || !response) {\n response = await this._respondFromCache({request, event});\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n } else {\n logs.push(`No response found in the '${this._cacheName}' cache.`);\n }\n }\n } else {\n // Keep the service worker alive while we put the request in the cache\n const responseClone = response.clone();\n const cachePut = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n // The event has been responded to so we can keep the SW alive to\n // respond to the request\n event.waitUntil(cachePut);\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n\n return response;\n }\n\n /**\n * Used if the network timeouts or fails to make the request.\n *\n * @param {Object} options\n * @param {Request} request The request to match in the cache\n * @param {Event} [options.event]\n * @return {Promise<Object>}\n *\n * @private\n */\n _respondFromCache({event, request}) {\n return cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n }\n}\n\nexport {NetworkFirst};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If the network request fails, this will throw a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass NetworkOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkOnly',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n } catch (err) {\n error = err;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('NetworkOnly', request));\n if (response) {\n logger.log(`Got response from network.`);\n } else {\n logger.log(`Unable to get a response from the network.`);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n}\n\nexport {NetworkOnly};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport {cacheOkAndOpaquePlugin} from './plugins/cacheOkAndOpaquePlugin.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}\n * request strategy.\n *\n * Resources are requested from both the cache and the network in parallel.\n * The strategy will respond with the cached version if available, otherwise\n * wait for the network response. The cache is updated with the network response\n * with each successful request.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass StaleWhileRevalidate {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n\n if (options.plugins) {\n let isUsingCacheWillUpdate =\n options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n } else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'StaleWhileRevalidate',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n\n const fetchAndCachePromise = this._getFromNetwork({request, event});\n\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache. Will update with the network response in the background.`);\n }\n\n if (event) {\n try {\n event.waitUntil(fetchAndCachePromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will wait for the network response.`);\n }\n try {\n response = await fetchAndCachePromise;\n } catch (err) {\n error = err;\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('StaleWhileRevalidate', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork({request, event}) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: response.clone(),\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n\n return response;\n }\n}\n\nexport {StaleWhileRevalidate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {CacheFirst} from './CacheFirst.mjs';\nimport {CacheOnly} from './CacheOnly.mjs';\nimport {NetworkFirst} from './NetworkFirst.mjs';\nimport {NetworkOnly} from './NetworkOnly.mjs';\nimport {StaleWhileRevalidate} from './StaleWhileRevalidate.mjs';\nimport './_version.mjs';\n\n\nconst mapping = {\n cacheFirst: CacheFirst,\n cacheOnly: CacheOnly,\n networkFirst: NetworkFirst,\n networkOnly: NetworkOnly,\n staleWhileRevalidate: StaleWhileRevalidate,\n};\n\nconst deprecate = (strategy) => {\n const StrategyCtr = mapping[strategy];\n\n return (options) => {\n if (process.env.NODE_ENV !== 'production') {\n const strategyCtrName = strategy[0].toUpperCase() + strategy.slice(1);\n logger.warn(`The 'workbox.strategies.${strategy}()' function has been ` +\n `deprecated and will be removed in a future version of Workbox.\\n` +\n `Please use 'new workbox.strategies.${strategyCtrName}()' instead.`);\n }\n return new StrategyCtr(options);\n };\n};\n\n/**\n * @function workbox.strategies.cacheFirst\n * @param {Object} options See the {@link workbox.strategies.CacheFirst}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst cacheFirst = deprecate('cacheFirst');\n\n/**\n * @function workbox.strategies.cacheOnly\n * @param {Object} options See the {@link workbox.strategies.CacheOnly}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst cacheOnly = deprecate('cacheOnly');\n\n/**\n * @function workbox.strategies.networkFirst\n * @param {Object} options See the {@link workbox.strategies.NetworkFirst}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst networkFirst = deprecate('networkFirst');\n\n/**\n * @function workbox.strategies.networkOnly\n * @param {Object} options See the {@link workbox.strategies.NetworkOnly}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst networkOnly = deprecate('networkOnly');\n\n/**\n * @function workbox.strategies.staleWhileRevalidate\n * @param {Object} options See the\n * {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.\n * @deprecated since v4.0.0\n */\nconst staleWhileRevalidate = deprecate('staleWhileRevalidate');\n\n/**\n * There are common caching strategies that most service workers will need\n * and use. This module provides simple implementations of these strategies.\n *\n * @namespace workbox.strategies\n */\n\nexport {\n CacheFirst,\n CacheOnly,\n NetworkFirst,\n NetworkOnly,\n StaleWhileRevalidate,\n\n // Deprecated...\n cacheFirst,\n cacheOnly,\n networkFirst,\n networkOnly,\n staleWhileRevalidate,\n};\n\n"],"names":["self","_","e","getFriendlyURL","url","urlObj","URL","location","origin","pathname","href","messages","strategyStart","strategyName","request","printFinalResponse","response","logger","groupCollapsed","log","groupEnd","CacheFirst","constructor","options","_cacheName","cacheNames","getRuntimeName","cacheName","_plugins","plugins","_fetchOptions","fetchOptions","_matchOptions","matchOptions","handle","event","makeRequest","logs","Request","assert","isInstance","moduleName","className","funcName","paramName","cacheWrapper","match","error","push","_getFromNetwork","err","WorkboxError","fetchWrapper","fetch","responseClone","clone","cachePutPromise","put","waitUntil","warn","CacheOnly","cacheOkAndOpaquePlugin","cacheWillUpdate","status","NetworkFirst","isUsingCacheWillUpdate","some","plugin","_networkTimeoutSeconds","networkTimeoutSeconds","isType","promises","timeoutId","id","promise","_getTimeoutPromise","networkPromise","_getNetworkPromise","Promise","race","timeoutPromise","resolve","onNetworkTimeout","_respondFromCache","setTimeout","clearTimeout","cachePut","NetworkOnly","StaleWhileRevalidate","fetchAndCachePromise","mapping","cacheFirst","cacheOnly","networkFirst","networkOnly","staleWhileRevalidate","deprecate","strategy","StrategyCtr","strategyCtrName","toUpperCase","slice"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,0BAAD,CAAJ,IAAkCC,CAAC,EAAnC;EAAsC,CAA1C,CAA0C,OAAMC,CAAN,EAAQ;;ECAlD;;;;;;;AAQA;EAGA,MAAMC,cAAc,GAAIC,GAAD,IAAS;EAC9B,QAAMC,MAAM,GAAG,IAAIC,GAAJ,CAAQF,GAAR,EAAaG,QAAb,CAAf;;EACA,MAAIF,MAAM,CAACG,MAAP,KAAkBD,QAAQ,CAACC,MAA/B,EAAuC;EACrC,WAAOH,MAAM,CAACI,QAAd;EACD;;EACD,SAAOJ,MAAM,CAACK,IAAd;EACD,CAND;;AAQA,EAAO,MAAMC,QAAQ,GAAG;EACtBC,EAAAA,aAAa,EAAE,CAACC,YAAD,EAAeC,OAAf,KAA4B,SAAQD,YAAa,MAAtB,GACvC,eAAcV,cAAc,CAACW,OAAO,CAACV,GAAT,CAAc,GAFvB;EAGtBW,EAAAA,kBAAkB,EAAGC,QAAD,IAAc;EAChC,QAAIA,QAAJ,EAAc;EACZC,MAAAA,iBAAM,CAACC,cAAP,CAAuB,+BAAvB;EACAD,MAAAA,iBAAM,CAACE,GAAP,CAAWH,QAAX;EACAC,MAAAA,iBAAM,CAACG,QAAP;EACD;EACF;EATqB,CAAjB;;ECnBP;;;;;;;AAQA,EAWA;;;;;;;;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MC,WAAW,GAAGR,OAAO,CAACO,QAAD,CAA3B;EAEA,SAAQ1E,OAAD,IAAa;EAClB,IAA2C;EACzC,YAAM4E,eAAe,GAAGF,QAAQ,CAAC,CAAD,CAAR,CAAYG,WAAZ,KAA4BH,QAAQ,CAACI,KAAT,CAAe,CAAf,CAApD;EACApF,MAAAA,iBAAM,CAAC0C,IAAP,CAAa,2BAA0BsC,QAAS,wBAApC,GACP,kEADO,GAEP,sCAAqCE,eAAgB,cAF1D;EAGD;;EACD,WAAO,IAAID,WAAJ,CAAgB3E,OAAhB,CAAP;EACD,GARD;EASD,CAZD;EAcA;;;;;;;;AAMA,QAAMoE,UAAU,GAAGK,SAAS,CAAC,YAAD,CAA5B;EAEA;;;;;;;AAMA,QAAMJ,SAAS,GAAGI,SAAS,CAAC,WAAD,CAA3B;EAEA;;;;;;;AAMA,QAAMH,YAAY,GAAGG,SAAS,CAAC,cAAD,CAA9B;EAEA;;;;;;;AAMA,QAAMF,WAAW,GAAGE,SAAS,CAAC,aAAD,CAA7B;EAEA;;;;;;;AAMA,QAAMD,oBAAoB,GAAGC,SAAS,CAAC,sBAAD,CAAtC;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.strategies=function(e,t,s,n,r){"use strict";try{self["workbox:strategies:4.3.1"]&&_()}catch(e){}class i{constructor(e={}){this.t=t.cacheNames.getRuntimeName(e.cacheName),this.s=e.plugins||[],this.i=e.fetchOptions||null,this.h=e.matchOptions||null}async handle({event:e,request:t}){return this.makeRequest({event:e,request:t||e.request})}async makeRequest({event:e,request:t}){"string"==typeof t&&(t=new Request(t));let n,i=await s.cacheWrapper.match({cacheName:this.t,request:t,event:e,matchOptions:this.h,plugins:this.s});if(!i)try{i=await this.u(t,e)}catch(e){n=e}if(!i)throw new r.WorkboxError("no-response",{url:t.url,error:n});return i}async u(e,t){const r=await n.fetchWrapper.fetch({request:e,event:t,fetchOptions:this.i,plugins:this.s}),i=r.clone(),h=s.cacheWrapper.put({cacheName:this.t,request:e,response:i,event:t,plugins:this.s});if(t)try{t.waitUntil(h)}catch(e){}return r}}class h{constructor(e={}){this.t=t.cacheNames.getRuntimeName(e.cacheName),this.s=e.plugins||[],this.h=e.matchOptions||null}async handle({event:e,request:t}){return this.makeRequest({event:e,request:t||e.request})}async makeRequest({event:e,request:t}){"string"==typeof t&&(t=new Request(t));const n=await s.cacheWrapper.match({cacheName:this.t,request:t,event:e,matchOptions:this.h,plugins:this.s});if(!n)throw new r.WorkboxError("no-response",{url:t.url});return n}}const u={cacheWillUpdate:({response:e})=>200===e.status||0===e.status?e:null};class a{constructor(e={}){if(this.t=t.cacheNames.getRuntimeName(e.cacheName),e.plugins){let t=e.plugins.some(e=>!!e.cacheWillUpdate);this.s=t?e.plugins:[u,...e.plugins]}else this.s=[u];this.o=e.networkTimeoutSeconds,this.i=e.fetchOptions||null,this.h=e.matchOptions||null}async handle({event:e,request:t}){return this.makeRequest({event:e,request:t||e.request})}async makeRequest({event:e,request:t}){const s=[];"string"==typeof t&&(t=new Request(t));const n=[];let i;if(this.o){const{id:r,promise:h}=this.l({request:t,event:e,logs:s});i=r,n.push(h)}const h=this.q({timeoutId:i,request:t,event:e,logs:s});n.push(h);let u=await Promise.race(n);if(u||(u=await h),!u)throw new r.WorkboxError("no-response",{url:t.url});return u}l({request:e,logs:t,event:s}){let n;return{promise:new Promise(t=>{n=setTimeout(async()=>{t(await this.p({request:e,event:s}))},1e3*this.o)}),id:n}}async q({timeoutId:e,request:t,logs:r,event:i}){let h,u;try{u=await n.fetchWrapper.fetch({request:t,event:i,fetchOptions:this.i,plugins:this.s})}catch(e){h=e}if(e&&clearTimeout(e),h||!u)u=await this.p({request:t,event:i});else{const e=u.clone(),n=s.cacheWrapper.put({cacheName:this.t,request:t,response:e,event:i,plugins:this.s});if(i)try{i.waitUntil(n)}catch(e){}}return u}p({event:e,request:t}){return s.cacheWrapper.match({cacheName:this.t,request:t,event:e,matchOptions:this.h,plugins:this.s})}}class c{constructor(e={}){this.t=t.cacheNames.getRuntimeName(e.cacheName),this.s=e.plugins||[],this.i=e.fetchOptions||null}async handle({event:e,request:t}){return this.makeRequest({event:e,request:t||e.request})}async makeRequest({event:e,request:t}){let s,i;"string"==typeof t&&(t=new Request(t));try{i=await n.fetchWrapper.fetch({request:t,event:e,fetchOptions:this.i,plugins:this.s})}catch(e){s=e}if(!i)throw new r.WorkboxError("no-response",{url:t.url,error:s});return i}}class o{constructor(e={}){if(this.t=t.cacheNames.getRuntimeName(e.cacheName),this.s=e.plugins||[],e.plugins){let t=e.plugins.some(e=>!!e.cacheWillUpdate);this.s=t?e.plugins:[u,...e.plugins]}else this.s=[u];this.i=e.fetchOptions||null,this.h=e.matchOptions||null}async handle({event:e,request:t}){return this.makeRequest({event:e,request:t||e.request})}async makeRequest({event:e,request:t}){"string"==typeof t&&(t=new Request(t));const n=this.u({request:t,event:e});let i,h=await s.cacheWrapper.match({cacheName:this.t,request:t,event:e,matchOptions:this.h,plugins:this.s});if(h){if(e)try{e.waitUntil(n)}catch(i){}}else try{h=await n}catch(e){i=e}if(!h)throw new r.WorkboxError("no-response",{url:t.url,error:i});return h}async u({request:e,event:t}){const r=await n.fetchWrapper.fetch({request:e,event:t,fetchOptions:this.i,plugins:this.s}),i=s.cacheWrapper.put({cacheName:this.t,request:e,response:r.clone(),event:t,plugins:this.s});if(t)try{t.waitUntil(i)}catch(e){}return r}}const l={cacheFirst:i,cacheOnly:h,networkFirst:a,networkOnly:c,staleWhileRevalidate:o},q=e=>{const t=l[e];return e=>new t(e)},w=q("cacheFirst"),p=q("cacheOnly"),v=q("networkFirst"),y=q("networkOnly"),m=q("staleWhileRevalidate");return e.CacheFirst=i,e.CacheOnly=h,e.NetworkFirst=a,e.NetworkOnly=c,e.StaleWhileRevalidate=o,e.cacheFirst=w,e.cacheOnly=p,e.networkFirst=v,e.networkOnly=y,e.staleWhileRevalidate=m,e}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-strategies.prod.js.map
{"version":3,"file":"workbox-strategies.prod.js","sources":["../_version.mjs","../CacheFirst.mjs","../CacheOnly.mjs","../plugins/cacheOkAndOpaquePlugin.mjs","../NetworkFirst.mjs","../NetworkOnly.mjs","../StaleWhileRevalidate.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:strategies:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}\n * request strategy.\n *\n * A cache first strategy is useful for assets that have been revisioned,\n * such as URLs like `/styles/example.a8f5f1.css`, since they\n * can be cached for long periods of time.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass CacheFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheFirst',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n\n let error;\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(\n `No response found in the '${this._cacheName}' cache. ` +\n `Will respond with a network request.`);\n }\n try {\n response = await this._getFromNetwork(request, event);\n } catch (err) {\n error = err;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n } else {\n logs.push(`Unable to get a response from the network.`);\n }\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(\n `Found a cached response in the '${this._cacheName}' cache.`);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('CacheFirst', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n\n /**\n * Handles the network and cache part of CacheFirst.\n *\n * @param {Request} request\n * @param {FetchEvent} [event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork(request, event) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n\n // Keep the service worker while we put the request to the cache\n const responseClone = response.clone();\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n\n return response;\n }\n}\n\nexport {CacheFirst};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n\n/**\n * An implementation of a\n * [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If there is no cache match, this will throw a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass CacheOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheOnly',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n\n const response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('CacheOnly', request));\n if (response) {\n logger.log(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n messages.printFinalResponse(response);\n } else {\n logger.log(`No response found in the '${this._cacheName}' cache.`);\n }\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url});\n }\n return response;\n }\n}\n\nexport {CacheOnly};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nexport const cacheOkAndOpaquePlugin = {\n /**\n * Returns a valid response (to allow caching) if the status is 200 (OK) or\n * 0 (opaque).\n *\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n *\n * @private\n */\n cacheWillUpdate: ({response}) => {\n if (response.status === 200 || response.status === 0) {\n return response;\n }\n return null;\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport {cacheOkAndOpaquePlugin} from './plugins/cacheOkAndOpaquePlugin.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}\n * request strategy.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass NetworkFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n * @param {number} options.networkTimeoutSeconds If set, any network requests\n * that fail to respond within the timeout will fallback to the cache.\n *\n * This option can be used to combat\n * \"[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}\"\n * scenarios.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n\n if (options.plugins) {\n let isUsingCacheWillUpdate =\n options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n } else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n\n this._networkTimeoutSeconds = options.networkTimeoutSeconds;\n if (process.env.NODE_ENV !== 'production') {\n if (this._networkTimeoutSeconds) {\n assert.isType(this._networkTimeoutSeconds, 'number', {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'constructor',\n paramName: 'networkTimeoutSeconds',\n });\n }\n }\n\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'handle',\n paramName: 'makeRequest',\n });\n }\n\n const promises = [];\n let timeoutId;\n\n if (this._networkTimeoutSeconds) {\n const {id, promise} = this._getTimeoutPromise({request, event, logs});\n timeoutId = id;\n promises.push(promise);\n }\n\n const networkPromise =\n this._getNetworkPromise({timeoutId, request, event, logs});\n promises.push(networkPromise);\n\n // Promise.race() will resolve as soon as the first promise resolves.\n let response = await Promise.race(promises);\n // If Promise.race() resolved with null, it might be due to a network\n // timeout + a cache miss. If that were to happen, we'd rather wait until\n // the networkPromise resolves instead of returning null.\n // Note that it's fine to await an already-resolved promise, so we don't\n // have to check to see if it's still \"in flight\".\n if (!response) {\n response = await networkPromise;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('NetworkFirst', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url});\n }\n return response;\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs array\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n _getTimeoutPromise({request, logs, event}) {\n let timeoutId;\n const timeoutPromise = new Promise((resolve) => {\n const onNetworkTimeout = async () => {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Timing out the network response at ` +\n `${this._networkTimeoutSeconds} seconds.`);\n }\n\n resolve(await this._respondFromCache({request, event}));\n };\n\n timeoutId = setTimeout(\n onNetworkTimeout,\n this._networkTimeoutSeconds * 1000,\n );\n });\n\n return {\n promise: timeoutPromise,\n id: timeoutId,\n };\n }\n\n /**\n * @param {Object} options\n * @param {number|undefined} options.timeoutId\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs Array.\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getNetworkPromise({timeoutId, request, logs, event}) {\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n } catch (err) {\n error = err;\n }\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n } else {\n logs.push(`Unable to get a response from the network. Will respond ` +\n `with a cached response.`);\n }\n }\n\n if (error || !response) {\n response = await this._respondFromCache({request, event});\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n } else {\n logs.push(`No response found in the '${this._cacheName}' cache.`);\n }\n }\n } else {\n // Keep the service worker alive while we put the request in the cache\n const responseClone = response.clone();\n const cachePut = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n // The event has been responded to so we can keep the SW alive to\n // respond to the request\n event.waitUntil(cachePut);\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n\n return response;\n }\n\n /**\n * Used if the network timeouts or fails to make the request.\n *\n * @param {Object} options\n * @param {Request} request The request to match in the cache\n * @param {Event} [options.event]\n * @return {Promise<Object>}\n *\n * @private\n */\n _respondFromCache({event, request}) {\n return cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n }\n}\n\nexport {NetworkFirst};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If the network request fails, this will throw a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass NetworkOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkOnly',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n } catch (err) {\n error = err;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('NetworkOnly', request));\n if (response) {\n logger.log(`Got response from network.`);\n } else {\n logger.log(`Unable to get a response from the network.`);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n}\n\nexport {NetworkOnly};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {cacheWrapper} from 'workbox-core/_private/cacheWrapper.mjs';\nimport {fetchWrapper} from 'workbox-core/_private/fetchWrapper.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\n\nimport {messages} from './utils/messages.mjs';\nimport {cacheOkAndOpaquePlugin} from './plugins/cacheOkAndOpaquePlugin.mjs';\nimport './_version.mjs';\n\n/**\n * An implementation of a\n * [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}\n * request strategy.\n *\n * Resources are requested from both the cache and the network in parallel.\n * The strategy will respond with the cached version if available, otherwise\n * wait for the network response. The cache is updated with the network response\n * with each successful request.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof workbox.strategies\n */\nclass StaleWhileRevalidate {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link workbox.core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n\n if (options.plugins) {\n let isUsingCacheWillUpdate =\n options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n } else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n\n this._fetchOptions = options.fetchOptions || null;\n this._matchOptions = options.matchOptions || null;\n }\n\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link workbox.routing.Router}.\n *\n * @param {Object} options\n * @param {Request} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({event, request}) {\n return this.makeRequest({\n event,\n request: request || event.request,\n });\n }\n /**\n * This method can be used to perform a make a standalone request outside the\n * context of the [Workbox Router]{@link workbox.routing.Router}.\n *\n * See \"[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)\"\n * for more usage information.\n *\n * @param {Object} options\n * @param {Request|string} options.request Either a\n * [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}\n * object, or a string URL, corresponding to the request to be made.\n * @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will\n * be called automatically to extend the service worker's lifetime.\n * @return {Promise<Response>}\n */\n async makeRequest({event, request}) {\n const logs = [];\n\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'StaleWhileRevalidate',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n\n const fetchAndCachePromise = this._getFromNetwork({request, event});\n\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache. Will update with the network response in the background.`);\n }\n\n if (event) {\n try {\n event.waitUntil(fetchAndCachePromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will wait for the network response.`);\n }\n try {\n response = await fetchAndCachePromise;\n } catch (err) {\n error = err;\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n messages.strategyStart('StaleWhileRevalidate', request));\n for (let log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n\n if (!response) {\n throw new WorkboxError('no-response', {url: request.url, error});\n }\n return response;\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork({request, event}) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: response.clone(),\n event,\n plugins: this._plugins,\n });\n\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n\n return response;\n }\n}\n\nexport {StaleWhileRevalidate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {CacheFirst} from './CacheFirst.mjs';\nimport {CacheOnly} from './CacheOnly.mjs';\nimport {NetworkFirst} from './NetworkFirst.mjs';\nimport {NetworkOnly} from './NetworkOnly.mjs';\nimport {StaleWhileRevalidate} from './StaleWhileRevalidate.mjs';\nimport './_version.mjs';\n\n\nconst mapping = {\n cacheFirst: CacheFirst,\n cacheOnly: CacheOnly,\n networkFirst: NetworkFirst,\n networkOnly: NetworkOnly,\n staleWhileRevalidate: StaleWhileRevalidate,\n};\n\nconst deprecate = (strategy) => {\n const StrategyCtr = mapping[strategy];\n\n return (options) => {\n if (process.env.NODE_ENV !== 'production') {\n const strategyCtrName = strategy[0].toUpperCase() + strategy.slice(1);\n logger.warn(`The 'workbox.strategies.${strategy}()' function has been ` +\n `deprecated and will be removed in a future version of Workbox.\\n` +\n `Please use 'new workbox.strategies.${strategyCtrName}()' instead.`);\n }\n return new StrategyCtr(options);\n };\n};\n\n/**\n * @function workbox.strategies.cacheFirst\n * @param {Object} options See the {@link workbox.strategies.CacheFirst}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst cacheFirst = deprecate('cacheFirst');\n\n/**\n * @function workbox.strategies.cacheOnly\n * @param {Object} options See the {@link workbox.strategies.CacheOnly}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst cacheOnly = deprecate('cacheOnly');\n\n/**\n * @function workbox.strategies.networkFirst\n * @param {Object} options See the {@link workbox.strategies.NetworkFirst}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst networkFirst = deprecate('networkFirst');\n\n/**\n * @function workbox.strategies.networkOnly\n * @param {Object} options See the {@link workbox.strategies.NetworkOnly}\n * constructor for more info.\n * @deprecated since v4.0.0\n */\nconst networkOnly = deprecate('networkOnly');\n\n/**\n * @function workbox.strategies.staleWhileRevalidate\n * @param {Object} options See the\n * {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.\n * @deprecated since v4.0.0\n */\nconst staleWhileRevalidate = deprecate('staleWhileRevalidate');\n\n/**\n * There are common caching strategies that most service workers will need\n * and use. This module provides simple implementations of these strategies.\n *\n * @namespace workbox.strategies\n */\n\nexport {\n CacheFirst,\n CacheOnly,\n NetworkFirst,\n NetworkOnly,\n StaleWhileRevalidate,\n\n // Deprecated...\n cacheFirst,\n cacheOnly,\n networkFirst,\n networkOnly,\n staleWhileRevalidate,\n};\n\n"],"names":["self","_","e","CacheFirst","constructor","options","_cacheName","cacheNames","getRuntimeName","cacheName","_plugins","plugins","_fetchOptions","fetchOptions","_matchOptions","matchOptions","event","request","this","makeRequest","Request","error","response","cacheWrapper","match","_getFromNetwork","err","WorkboxError","url","fetchWrapper","fetch","responseClone","clone","cachePutPromise","put","waitUntil","CacheOnly","cacheOkAndOpaquePlugin","cacheWillUpdate","status","NetworkFirst","isUsingCacheWillUpdate","some","plugin","_networkTimeoutSeconds","networkTimeoutSeconds","logs","promises","timeoutId","id","promise","_getTimeoutPromise","push","networkPromise","_getNetworkPromise","Promise","race","resolve","setTimeout","async","_respondFromCache","clearTimeout","cachePut","NetworkOnly","StaleWhileRevalidate","fetchAndCachePromise","mapping","cacheFirst","cacheOnly","networkFirst","networkOnly","staleWhileRevalidate","deprecate","strategy","StrategyCtr"],"mappings":"uFAAA,IAAIA,KAAK,6BAA6BC,IAAI,MAAMC,ICgChD,MAAMC,EAaJC,YAAYC,EAAU,SACfC,EAAaC,aAAWC,eAAeH,EAAQI,gBAC/CC,EAAWL,EAAQM,SAAW,QAC9BC,EAAgBP,EAAQQ,cAAgB,UACxCC,EAAgBT,EAAQU,cAAgB,mBAalCC,MAACA,EAADC,QAAQA,WACZC,KAAKC,YAAY,CACtBH,MAAAA,EACAC,QAASA,GAAWD,EAAMC,6BAmBZD,MAACA,EAADC,QAAQA,IAGD,iBAAZA,IACTA,EAAU,IAAIG,QAAQH,QAoBpBI,EARAC,QAAiBC,eAAaC,MAAM,CACtCf,UAAWS,KAAKZ,EAChBW,QAAAA,EACAD,MAAAA,EACAD,aAAcG,KAAKJ,EACnBH,QAASO,KAAKR,QAIXY,MAODA,QAAiBJ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AAWD,EAAMC,6BAkBZD,MAACA,EAADC,QAAQA,IAGD,iBAAZA,IACTA,EAAU,IAAIG,QAAQH,UAYlBgD,EAAuB/C,KAAKO,EAAgB,CAACR,QAAAA,EAASD,MAAAA,QASxDK,EAPAC,QAAiBC,eAAaC,MAAM,CACtCf,UAAWS,KAAKZ,EAChBW,QAAAA,EACAD,MAAAA,EACAD,aAAcG,KAAKJ,EACnBH,QAASO,KAAKR,OAGZY,MAMEN,MAEAA,EAAMmB,UAAU8B,GAChB,MAAO5C,cAaTC,QAAiB2C,EACjB,MAAOvC,GACPL,EAAQK,MAcPJ,QACG,IAAIK,eAAa,cAAe,CAACC,IAAKX,EAAQW,IAAKP,MAAAA,WAEpDC,WAWaL,QAACA,EAADD,MAAUA,UACxBM,QAAiBO,eAAaC,MAAM,CACxCb,QAAAA,EACAD,MAAAA,EACAH,aAAcK,KAAKN,EACnBD,QAASO,KAAKR,IAGVuB,EAAkBV,eAAaW,IAAI,CACvCzB,UAAWS,KAAKZ,EAChBW,QAAAA,EACAK,SAAUA,EAASU,QACnBhB,MAAAA,EACAL,QAASO,KAAKR,OAGZM,MAEAA,EAAMmB,UAAUF,GAChB,MAAOZ,WAQJC,GC9LX,MAAM4C,EAAU,CACdC,WAAYhE,EACZiE,UAAWhC,EACXiC,aAAc7B,EACd8B,YAAaP,EACbQ,qBAAsBP,GAGlBQ,EAAaC,UACXC,EAAcR,EAAQO,UAEpBpE,GAOC,IAAIqE,EAAYrE,IAUrB8D,EAAaK,EAAU,cAQvBJ,EAAYI,EAAU,aAQtBH,EAAeG,EAAU,gBAQzBF,EAAcE,EAAU,eAQxBD,EAAuBC,EAAU"}
\ No newline at end of file
this.workbox = this.workbox || {};
this.workbox.streams = (function (exports, logger_mjs, assert_mjs) {
'use strict';
try {
self['workbox:streams:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Takes either a Response, a ReadableStream, or a
* [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the
* ReadableStreamReader object associated with it.
*
* @param {workbox.streams.StreamSource} source
* @return {ReadableStreamReader}
* @private
*/
function _getReaderFromSource(source) {
if (source.body && source.body.getReader) {
return source.body.getReader();
}
if (source.getReader) {
return source.getReader();
} // TODO: This should be possible to do by constructing a ReadableStream, but
// I can't get it to work. As a hack, construct a new Response, and use the
// reader associated with its body.
return new Response(source).body.getReader();
}
/**
* Takes multiple source Promises, each of which could resolve to a Response, a
* ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).
*
* Returns an object exposing a ReadableStream with each individual stream's
* data returned in sequence, along with a Promise which signals when the
* stream is finished (useful for passing to a FetchEvent's waitUntil()).
*
* @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises
* @return {Object<{done: Promise, stream: ReadableStream}>}
*
* @memberof workbox.streams
*/
function concatenate(sourcePromises) {
{
assert_mjs.assert.isArray(sourcePromises, {
moduleName: 'workbox-streams',
funcName: 'concatenate',
paramName: 'sourcePromises'
});
}
const readerPromises = sourcePromises.map(sourcePromise => {
return Promise.resolve(sourcePromise).then(source => {
return _getReaderFromSource(source);
});
});
let fullyStreamedResolve;
let fullyStreamedReject;
const done = new Promise((resolve, reject) => {
fullyStreamedResolve = resolve;
fullyStreamedReject = reject;
});
let i = 0;
const logMessages = [];
const stream = new ReadableStream({
pull(controller) {
return readerPromises[i].then(reader => reader.read()).then(result => {
if (result.done) {
{
logMessages.push(['Reached the end of source:', sourcePromises[i]]);
}
i++;
if (i >= readerPromises.length) {
// Log all the messages in the group at once in a single group.
{
logger_mjs.logger.groupCollapsed(`Concatenating ${readerPromises.length} sources.`);
for (const message of logMessages) {
if (Array.isArray(message)) {
logger_mjs.logger.log(...message);
} else {
logger_mjs.logger.log(message);
}
}
logger_mjs.logger.log('Finished reading all sources.');
logger_mjs.logger.groupEnd();
}
controller.close();
fullyStreamedResolve();
return;
}
return this.pull(controller);
} else {
controller.enqueue(result.value);
}
}).catch(error => {
{
logger_mjs.logger.error('An error occurred:', error);
}
fullyStreamedReject(error);
throw error;
});
},
cancel() {
{
logger_mjs.logger.warn('The ReadableStream was cancelled.');
}
fullyStreamedResolve();
}
});
return {
done,
stream
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* This is a utility method that determines whether the current browser supports
* the features required to create streamed responses. Currently, it checks if
* [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
* is available.
*
* @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
* `'text/html'` will be used by default.
* @return {boolean} `true`, if the current browser meets the requirements for
* streaming responses, and `false` otherwise.
*
* @memberof workbox.streams
*/
function createHeaders(headersInit = {}) {
// See https://github.com/GoogleChrome/workbox/issues/1461
const headers = new Headers(headersInit);
if (!headers.has('content-type')) {
headers.set('content-type', 'text/html');
}
return headers;
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Takes multiple source Promises, each of which could resolve to a Response, a
* ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),
* along with a
* [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).
*
* Returns an object exposing a Response whose body consists of each individual
* stream's data returned in sequence, along with a Promise which signals when
* the stream is finished (useful for passing to a FetchEvent's waitUntil()).
*
* @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises
* @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
* `'text/html'` will be used by default.
* @return {Object<{done: Promise, response: Response}>}
*
* @memberof workbox.streams
*/
function concatenateToResponse(sourcePromises, headersInit) {
const {
done,
stream
} = concatenate(sourcePromises);
const headers = createHeaders(headersInit);
const response = new Response(stream, {
headers
});
return {
done,
response
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
let cachedIsSupported = undefined;
/**
* This is a utility method that determines whether the current browser supports
* the features required to create streamed responses. Currently, it checks if
* [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
* can be created.
*
* @return {boolean} `true`, if the current browser meets the requirements for
* streaming responses, and `false` otherwise.
*
* @memberof workbox.streams
*/
function isSupported() {
if (cachedIsSupported === undefined) {
// See https://github.com/GoogleChrome/workbox/issues/1473
try {
new ReadableStream({
start() {}
});
cachedIsSupported = true;
} catch (error) {
cachedIsSupported = false;
}
}
return cachedIsSupported;
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A shortcut to create a strategy that could be dropped-in to Workbox's router.
*
* On browsers that do not support constructing new `ReadableStream`s, this
* strategy will automatically wait for all the `sourceFunctions` to complete,
* and create a final response that concatenates their values together.
*
* @param {
* Array<function(workbox.routing.Route~handlerCallback)>} sourceFunctions
* Each function should return a {@link workbox.streams.StreamSource} (or a
* Promise which resolves to one).
* @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
* `'text/html'` will be used by default.
* @return {workbox.routing.Route~handlerCallback}
*
* @memberof workbox.streams
*/
function strategy(sourceFunctions, headersInit) {
return async ({
event,
url,
params
}) => {
if (isSupported()) {
const {
done,
response
} = concatenateToResponse(sourceFunctions.map(fn => fn({
event,
url,
params
})), headersInit);
event.waitUntil(done);
return response;
}
{
logger_mjs.logger.log(`The current browser doesn't support creating response ` + `streams. Falling back to non-streaming response instead.`);
} // Fallback to waiting for everything to finish, and concatenating the
// responses.
const parts = await Promise.all(sourceFunctions.map(sourceFunction => sourceFunction({
event,
url,
params
})).map(async responsePromise => {
const response = await responsePromise;
if (response instanceof Response) {
return response.blob();
} // Otherwise, assume it's something like a string which can be used
// as-is when constructing the final composite blob.
return response;
}));
const headers = createHeaders(headersInit); // Constructing a new Response from a Blob source is well-supported.
// So is constructing a new Blob from multiple source Blobs or strings.
return new Response(new Blob(parts), {
headers
});
};
}
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.concatenate = concatenate;
exports.concatenateToResponse = concatenateToResponse;
exports.isSupported = isSupported;
exports.strategy = strategy;
return exports;
}({}, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-streams.dev.js.map
{"version":3,"file":"workbox-streams.dev.js","sources":["../_version.mjs","../concatenate.mjs","../utils/createHeaders.mjs","../concatenateToResponse.mjs","../isSupported.mjs","../strategy.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:streams:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport './_version.mjs';\n\n/**\n * Takes either a Response, a ReadableStream, or a\n * [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the\n * ReadableStreamReader object associated with it.\n *\n * @param {workbox.streams.StreamSource} source\n * @return {ReadableStreamReader}\n * @private\n */\nfunction _getReaderFromSource(source) {\n if (source.body && source.body.getReader) {\n return source.body.getReader();\n }\n\n if (source.getReader) {\n return source.getReader();\n }\n\n // TODO: This should be possible to do by constructing a ReadableStream, but\n // I can't get it to work. As a hack, construct a new Response, and use the\n // reader associated with its body.\n return new Response(source).body.getReader();\n}\n\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).\n *\n * Returns an object exposing a ReadableStream with each individual stream's\n * data returned in sequence, along with a Promise which signals when the\n * stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises\n * @return {Object<{done: Promise, stream: ReadableStream}>}\n *\n * @memberof workbox.streams\n */\nfunction concatenate(sourcePromises) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(sourcePromises, {\n moduleName: 'workbox-streams',\n funcName: 'concatenate',\n paramName: 'sourcePromises',\n });\n }\n\n const readerPromises = sourcePromises.map((sourcePromise) => {\n return Promise.resolve(sourcePromise).then((source) => {\n return _getReaderFromSource(source);\n });\n });\n\n let fullyStreamedResolve;\n let fullyStreamedReject;\n const done = new Promise((resolve, reject) => {\n fullyStreamedResolve = resolve;\n fullyStreamedReject = reject;\n });\n\n let i = 0;\n const logMessages = [];\n const stream = new ReadableStream({\n pull(controller) {\n return readerPromises[i]\n .then((reader) => reader.read())\n .then((result) => {\n if (result.done) {\n if (process.env.NODE_ENV !== 'production') {\n logMessages.push(['Reached the end of source:',\n sourcePromises[i]]);\n }\n\n i++;\n if (i >= readerPromises.length) {\n // Log all the messages in the group at once in a single group.\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n `Concatenating ${readerPromises.length} sources.`);\n for (const message of logMessages) {\n if (Array.isArray(message)) {\n logger.log(...message);\n } else {\n logger.log(message);\n }\n }\n logger.log('Finished reading all sources.');\n logger.groupEnd();\n }\n\n controller.close();\n fullyStreamedResolve();\n return;\n }\n\n return this.pull(controller);\n } else {\n controller.enqueue(result.value);\n }\n }).catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('An error occurred:', error);\n }\n fullyStreamedReject(error);\n throw error;\n });\n },\n\n cancel() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('The ReadableStream was cancelled.');\n }\n\n fullyStreamedResolve();\n },\n });\n\n return {done, stream};\n}\n\nexport {concatenate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * is available.\n *\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof workbox.streams\n */\nfunction createHeaders(headersInit = {}) {\n // See https://github.com/GoogleChrome/workbox/issues/1461\n const headers = new Headers(headersInit);\n if (!headers.has('content-type')) {\n headers.set('content-type', 'text/html');\n }\n return headers;\n}\n\nexport {createHeaders};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {createHeaders} from './utils/createHeaders.mjs';\nimport {concatenate} from './concatenate.mjs';\n\nimport './_version.mjs';\n\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),\n * along with a\n * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).\n *\n * Returns an object exposing a Response whose body consists of each individual\n * stream's data returned in sequence, along with a Promise which signals when\n * the stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {Object<{done: Promise, response: Response}>}\n *\n * @memberof workbox.streams\n */\nfunction concatenateToResponse(sourcePromises, headersInit) {\n const {done, stream} = concatenate(sourcePromises);\n\n const headers = createHeaders(headersInit);\n const response = new Response(stream, {headers});\n\n return {done, response};\n}\n\nexport {concatenateToResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\nlet cachedIsSupported = undefined;\n\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * can be created.\n *\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof workbox.streams\n */\nfunction isSupported() {\n if (cachedIsSupported === undefined) {\n // See https://github.com/GoogleChrome/workbox/issues/1473\n try {\n new ReadableStream({start() {}});\n cachedIsSupported = true;\n } catch (error) {\n cachedIsSupported = false;\n }\n }\n\n return cachedIsSupported;\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {createHeaders} from './utils/createHeaders.mjs';\nimport {concatenateToResponse} from './concatenateToResponse.mjs';\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * A shortcut to create a strategy that could be dropped-in to Workbox's router.\n *\n * On browsers that do not support constructing new `ReadableStream`s, this\n * strategy will automatically wait for all the `sourceFunctions` to complete,\n * and create a final response that concatenates their values together.\n *\n * @param {\n * Array<function(workbox.routing.Route~handlerCallback)>} sourceFunctions\n * Each function should return a {@link workbox.streams.StreamSource} (or a\n * Promise which resolves to one).\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {workbox.routing.Route~handlerCallback}\n *\n * @memberof workbox.streams\n */\nexport function strategy(sourceFunctions, headersInit) {\n return async ({event, url, params}) => {\n if (isSupported()) {\n const {done, response} = concatenateToResponse(sourceFunctions.map(\n (fn) => fn({event, url, params})), headersInit);\n event.waitUntil(done);\n return response;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The current browser doesn't support creating response ` +\n `streams. Falling back to non-streaming response instead.`);\n }\n\n // Fallback to waiting for everything to finish, and concatenating the\n // responses.\n const parts = await Promise.all(\n sourceFunctions.map(\n (sourceFunction) => sourceFunction({event, url, params})\n ).map(async (responsePromise) => {\n const response = await responsePromise;\n if (response instanceof Response) {\n return response.blob();\n }\n\n // Otherwise, assume it's something like a string which can be used\n // as-is when constructing the final composite blob.\n return response;\n })\n );\n\n const headers = createHeaders(headersInit);\n // Constructing a new Response from a Blob source is well-supported.\n // So is constructing a new Blob from multiple source Blobs or strings.\n return new Response(new Blob(parts), {headers});\n };\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {concatenate} from './concatenate.mjs';\nimport {concatenateToResponse} from './concatenateToResponse.mjs';\nimport {isSupported} from './isSupported.mjs';\nimport {strategy} from './strategy.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.streams\n */\n\nexport {\n concatenate,\n concatenateToResponse,\n isSupported,\n strategy,\n};\n"],"names":["self","_","e","_getReaderFromSource","source","body","getReader","Response","concatenate","sourcePromises","assert","isArray","moduleName","funcName","paramName","readerPromises","map","sourcePromise","Promise","resolve","then","fullyStreamedResolve","fullyStreamedReject","done","reject","i","logMessages","stream","ReadableStream","pull","controller","reader","read","result","push","length","logger","groupCollapsed","message","Array","log","groupEnd","close","enqueue","value","catch","error","cancel","warn","createHeaders","headersInit","headers","Headers","has","set","concatenateToResponse","response","cachedIsSupported","undefined","isSupported","start","strategy","sourceFunctions","event","url","params","fn","waitUntil","parts","all","sourceFunction","responsePromise","blob","Blob"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,uBAAD,CAAJ,IAA+BC,CAAC,EAAhC;EAAmC,CAAvC,CAAuC,OAAMC,CAAN,EAAQ;;ECA/C;;;;;;;AAQA,EAKA;;;;;;;;;;EASA,SAASC,oBAAT,CAA8BC,MAA9B,EAAsC;EACpC,MAAIA,MAAM,CAACC,IAAP,IAAeD,MAAM,CAACC,IAAP,CAAYC,SAA/B,EAA0C;EACxC,WAAOF,MAAM,CAACC,I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EAAQC,IAAAA,GAAR;EAAaC,IAAAA;EAAb,GAAP,KAAgC;EACrC,QAAIN,WAAW,EAAf,EAAmB;EACjB,YAAM;EAACpC,QAAAA,IAAD;EAAOiC,QAAAA;EAAP,UAAmBD,qBAAqB,CAACO,eAAe,CAAC9C,GAAhB,CAC1CkD,EAAD,IAAQA,EAAE,CAAC;EAACH,QAAAA,KAAD;EAAQC,QAAAA,GAAR;EAAaC,QAAAA;EAAb,OAAD,CADiC,CAAD,EACPf,WADO,CAA9C;EAEAa,MAAAA,KAAK,CAACI,SAAN,CAAgB5C,IAAhB;EACA,aAAOiC,QAAP;EACD;;EAED,IAA2C;EACzCpB,MAAAA,iBAAM,CAACI,GAAP,CAAY,wDAAD,GACR,0DADH;EAED,KAXoC;EAcrC;;;EACA,UAAM4B,KAAK,GAAG,MAAMlD,OAAO,CAACmD,GAAR,CAChBP,eAAe,CAAC9C,GAAhB,CACKsD,cAAD,IAAoBA,cAAc,CAAC;EAACP,MAAAA,KAAD;EAAQC,MAAAA,GAAR;EAAaC,MAAAA;EAAb,KAAD,CADtC,EAEEjD,GAFF,CAEM,MAAOuD,eAAP,IAA2B;EAC/B,YAAMf,QAAQ,GAAG,MAAMe,eAAvB;;EACA,UAAIf,QAAQ,YAAYjD,QAAxB,EAAkC;EAChC,eAAOiD,QAAQ,CAACgB,IAAT,EAAP;EACD,OAJ8B;EAO/B;;;EACA,aAAOhB,QAAP;EACD,KAXD,CADgB,CAApB;EAeA,UAAML,OAAO,GAAGF,aAAa,CAACC,WAAD,CAA7B,CA9BqC;EAgCrC;;EACA,WAAO,IAAI3C,QAAJ,CAAa,IAAIkE,IAAJ,CAASL,KAAT,CAAb,EAA8B;EAACjB,MAAAA;EAAD,KAA9B,CAAP;EACD,GAlCD;EAmCD;;ECrED;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
this.workbox=this.workbox||{},this.workbox.streams=function(e){"use strict";try{self["workbox:streams:4.3.1"]&&_()}catch(e){}function n(e){const n=e.map(e=>Promise.resolve(e).then(e=>(function(e){return e.body&&e.body.getReader?e.body.getReader():e.getReader?e.getReader():new Response(e).body.getReader()})(e)));let t,r;const s=new Promise((e,n)=>{t=e,r=n});let o=0;return{done:s,stream:new ReadableStream({pull(e){return n[o].then(e=>e.read()).then(r=>{if(r.done)return++o>=n.length?(e.close(),void t()):this.pull(e);e.enqueue(r.value)}).catch(e=>{throw r(e),e})},cancel(){t()}})}}function t(e={}){const n=new Headers(e);return n.has("content-type")||n.set("content-type","text/html"),n}function r(e,r){const{done:s,stream:o}=n(e),a=t(r);return{done:s,response:new Response(o,{headers:a})}}let s=void 0;function o(){if(void 0===s)try{new ReadableStream({start(){}}),s=!0}catch(e){s=!1}return s}return e.concatenate=n,e.concatenateToResponse=r,e.isSupported=o,e.strategy=function(e,n){return async({event:s,url:a,params:c})=>{if(o()){const{done:t,response:o}=r(e.map(e=>e({event:s,url:a,params:c})),n);return s.waitUntil(t),o}const i=await Promise.all(e.map(e=>e({event:s,url:a,params:c})).map(async e=>{const n=await e;return n instanceof Response?n.blob():n})),u=t(n);return new Response(new Blob(i),{headers:u})}},e}({});
//# sourceMappingURL=workbox-streams.prod.js.map
{"version":3,"file":"workbox-streams.prod.js","sources":["../_version.mjs","../concatenate.mjs","../utils/createHeaders.mjs","../concatenateToResponse.mjs","../isSupported.mjs","../strategy.mjs"],"sourcesContent":["try{self['workbox:streams:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\n\nimport './_version.mjs';\n\n/**\n * Takes either a Response, a ReadableStream, or a\n * [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the\n * ReadableStreamReader object associated with it.\n *\n * @param {workbox.streams.StreamSource} source\n * @return {ReadableStreamReader}\n * @private\n */\nfunction _getReaderFromSource(source) {\n if (source.body && source.body.getReader) {\n return source.body.getReader();\n }\n\n if (source.getReader) {\n return source.getReader();\n }\n\n // TODO: This should be possible to do by constructing a ReadableStream, but\n // I can't get it to work. As a hack, construct a new Response, and use the\n // reader associated with its body.\n return new Response(source).body.getReader();\n}\n\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).\n *\n * Returns an object exposing a ReadableStream with each individual stream's\n * data returned in sequence, along with a Promise which signals when the\n * stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises\n * @return {Object<{done: Promise, stream: ReadableStream}>}\n *\n * @memberof workbox.streams\n */\nfunction concatenate(sourcePromises) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(sourcePromises, {\n moduleName: 'workbox-streams',\n funcName: 'concatenate',\n paramName: 'sourcePromises',\n });\n }\n\n const readerPromises = sourcePromises.map((sourcePromise) => {\n return Promise.resolve(sourcePromise).then((source) => {\n return _getReaderFromSource(source);\n });\n });\n\n let fullyStreamedResolve;\n let fullyStreamedReject;\n const done = new Promise((resolve, reject) => {\n fullyStreamedResolve = resolve;\n fullyStreamedReject = reject;\n });\n\n let i = 0;\n const logMessages = [];\n const stream = new ReadableStream({\n pull(controller) {\n return readerPromises[i]\n .then((reader) => reader.read())\n .then((result) => {\n if (result.done) {\n if (process.env.NODE_ENV !== 'production') {\n logMessages.push(['Reached the end of source:',\n sourcePromises[i]]);\n }\n\n i++;\n if (i >= readerPromises.length) {\n // Log all the messages in the group at once in a single group.\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(\n `Concatenating ${readerPromises.length} sources.`);\n for (const message of logMessages) {\n if (Array.isArray(message)) {\n logger.log(...message);\n } else {\n logger.log(message);\n }\n }\n logger.log('Finished reading all sources.');\n logger.groupEnd();\n }\n\n controller.close();\n fullyStreamedResolve();\n return;\n }\n\n return this.pull(controller);\n } else {\n controller.enqueue(result.value);\n }\n }).catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('An error occurred:', error);\n }\n fullyStreamedReject(error);\n throw error;\n });\n },\n\n cancel() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('The ReadableStream was cancelled.');\n }\n\n fullyStreamedResolve();\n },\n });\n\n return {done, stream};\n}\n\nexport {concatenate};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * is available.\n *\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof workbox.streams\n */\nfunction createHeaders(headersInit = {}) {\n // See https://github.com/GoogleChrome/workbox/issues/1461\n const headers = new Headers(headersInit);\n if (!headers.has('content-type')) {\n headers.set('content-type', 'text/html');\n }\n return headers;\n}\n\nexport {createHeaders};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {createHeaders} from './utils/createHeaders.mjs';\nimport {concatenate} from './concatenate.mjs';\n\nimport './_version.mjs';\n\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),\n * along with a\n * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).\n *\n * Returns an object exposing a Response whose body consists of each individual\n * stream's data returned in sequence, along with a Promise which signals when\n * the stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<workbox.streams.StreamSource>>} sourcePromises\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {Object<{done: Promise, response: Response}>}\n *\n * @memberof workbox.streams\n */\nfunction concatenateToResponse(sourcePromises, headersInit) {\n const {done, stream} = concatenate(sourcePromises);\n\n const headers = createHeaders(headersInit);\n const response = new Response(stream, {headers});\n\n return {done, response};\n}\n\nexport {concatenateToResponse};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\nlet cachedIsSupported = undefined;\n\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * can be created.\n *\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof workbox.streams\n */\nfunction isSupported() {\n if (cachedIsSupported === undefined) {\n // See https://github.com/GoogleChrome/workbox/issues/1473\n try {\n new ReadableStream({start() {}});\n cachedIsSupported = true;\n } catch (error) {\n cachedIsSupported = false;\n }\n }\n\n return cachedIsSupported;\n}\n\nexport {isSupported};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {logger} from 'workbox-core/_private/logger.mjs';\n\nimport {createHeaders} from './utils/createHeaders.mjs';\nimport {concatenateToResponse} from './concatenateToResponse.mjs';\nimport {isSupported} from './isSupported.mjs';\n\nimport './_version.mjs';\n\n/**\n * A shortcut to create a strategy that could be dropped-in to Workbox's router.\n *\n * On browsers that do not support constructing new `ReadableStream`s, this\n * strategy will automatically wait for all the `sourceFunctions` to complete,\n * and create a final response that concatenates their values together.\n *\n * @param {\n * Array<function(workbox.routing.Route~handlerCallback)>} sourceFunctions\n * Each function should return a {@link workbox.streams.StreamSource} (or a\n * Promise which resolves to one).\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {workbox.routing.Route~handlerCallback}\n *\n * @memberof workbox.streams\n */\nexport function strategy(sourceFunctions, headersInit) {\n return async ({event, url, params}) => {\n if (isSupported()) {\n const {done, response} = concatenateToResponse(sourceFunctions.map(\n (fn) => fn({event, url, params})), headersInit);\n event.waitUntil(done);\n return response;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The current browser doesn't support creating response ` +\n `streams. Falling back to non-streaming response instead.`);\n }\n\n // Fallback to waiting for everything to finish, and concatenating the\n // responses.\n const parts = await Promise.all(\n sourceFunctions.map(\n (sourceFunction) => sourceFunction({event, url, params})\n ).map(async (responsePromise) => {\n const response = await responsePromise;\n if (response instanceof Response) {\n return response.blob();\n }\n\n // Otherwise, assume it's something like a string which can be used\n // as-is when constructing the final composite blob.\n return response;\n })\n );\n\n const headers = createHeaders(headersInit);\n // Constructing a new Response from a Blob source is well-supported.\n // So is constructing a new Blob from multiple source Blobs or strings.\n return new Response(new Blob(parts), {headers});\n };\n}\n"],"names":["self","_","e","concatenate","sourcePromises","readerPromises","map","sourcePromise","Promise","resolve","then","source","body","getReader","Response","_getReaderFromSource","fullyStreamedResolve","fullyStreamedReject","done","reject","i","stream","ReadableStream","pull","controller","reader","read","result","length","close","this","enqueue","value","catch","error","cancel","createHeaders","headersInit","headers","Headers","has","set","concatenateToResponse","response","cachedIsSupported","undefined","isSupported","start","sourceFunctions","async","event","url","params","fn","waitUntil","parts","all","sourceFunction","responsePromise","blob","Blob"],"mappings":"4EAAA,IAAIA,KAAK,0BAA0BC,IAAI,MAAMC,ICkD7C,SAASC,EAAYC,SASbC,EAAiBD,EAAeE,IAAKC,GAClCC,QAAQC,QAAQF,GAAeG,KAAMC,IAtChD,SAA8BA,UACxBA,EAAOC,MAAQD,EAAOC,KAAKC,UACtBF,EAAOC,KAAKC,YAGjBF,EAAOE,UACFF,EAAOE,YAMT,IAAIC,SAASH,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ACf6B,EAASgB,OAKXhB,KAIPL,EAAUF,EAAcC,UAGvB,IAAIvB,SAAS,IAAI8C,KAAKL,GAAQ,CAACjB,QAAAA"}
\ No newline at end of file
!function(){"use strict";try{self["workbox:sw:4.3.1"]&&_()}catch(t){}const t="https://storage.googleapis.com/workbox-cdn/releases/4.3.1",e={backgroundSync:"background-sync",broadcastUpdate:"broadcast-update",cacheableResponse:"cacheable-response",core:"core",expiration:"expiration",googleAnalytics:"offline-ga",navigationPreload:"navigation-preload",precaching:"precaching",rangeRequests:"range-requests",routing:"routing",strategies:"strategies",streams:"streams"};self.workbox=new class{constructor(){return this.v={},this.t={debug:"localhost"===self.location.hostname,modulePathPrefix:null,modulePathCb:null},this.s=this.t.debug?"dev":"prod",this.o=!1,new Proxy(this,{get(t,s){if(t[s])return t[s];const o=e[s];return o&&t.loadModule(`workbox-${o}`),t[s]}})}setConfig(t={}){if(this.o)throw new Error("Config must be set before accessing workbox.* modules");Object.assign(this.t,t),this.s=this.t.debug?"dev":"prod"}loadModule(t){const e=this.i(t);try{importScripts(e),this.o=!0}catch(s){throw console.error(`Unable to import module '${t}' from '${e}'.`),s}}i(e){if(this.t.modulePathCb)return this.t.modulePathCb(e,this.t.debug);let s=[t];const o=`${e}.${this.s}.js`,r=this.t.modulePathPrefix;return r&&""===(s=r.split("/"))[s.length-1]&&s.splice(s.length-1,1),s.push(o),s.join("/")}}}();
//# sourceMappingURL=workbox-sw.js.map
{"version":3,"file":"workbox-sw.js","sources":["../_version.mjs","../controllers/WorkboxSW.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:sw:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst CDN_PATH = `WORKBOX_CDN_ROOT_URL`;\n\nconst MODULE_KEY_TO_NAME_MAPPING = {\n // TODO(philipwalton): add jsdoc tags to associate these with their module.\n // @name backgroundSync\n // @memberof workbox\n // @see module:workbox-background-sync\n backgroundSync: 'background-sync',\n broadcastUpdate: 'broadcast-update',\n cacheableResponse: 'cacheable-response',\n core: 'core',\n expiration: 'expiration',\n googleAnalytics: 'offline-ga',\n navigationPreload: 'navigation-preload',\n precaching: 'precaching',\n rangeRequests: 'range-requests',\n routing: 'routing',\n strategies: 'strategies',\n streams: 'streams',\n};\n\n/**\n * This class can be used to make it easy to use the various parts of\n * Workbox.\n *\n * @private\n */\nexport class WorkboxSW {\n /**\n * Creates a proxy that automatically loads workbox namespaces on demand.\n *\n * @private\n */\n constructor() {\n this.v = {};\n this._options = {\n debug: self.location.hostname === 'localhost',\n modulePathPrefix: null,\n modulePathCb: null,\n };\n\n this._env = this._options.debug ? 'dev' : 'prod';\n this._modulesLoaded = false;\n\n return new Proxy(this, {\n get(target, key) {\n if (target[key]) {\n return target[key];\n }\n\n const moduleName = MODULE_KEY_TO_NAME_MAPPING[key];\n if (moduleName) {\n target.loadModule(`workbox-${moduleName}`);\n }\n\n return target[key];\n },\n });\n }\n\n /**\n * Updates the configuration options. You can specify whether to treat as a\n * debug build and whether to use a CDN or a specific path when importing\n * other workbox-modules\n *\n * @param {Object} [options]\n * @param {boolean} [options.debug] If true, `dev` builds are using, otherwise\n * `prod` builds are used. By default, `prod` is used unless on localhost.\n * @param {Function} [options.modulePathPrefix] To avoid using the CDN with\n * `workbox-sw` set the path prefix of where modules should be loaded from.\n * For example `modulePathPrefix: '/third_party/workbox/v3.0.0/'`.\n * @param {workbox~ModulePathCallback} [options.modulePathCb] If defined,\n * this callback will be responsible for determining the path of each\n * workbox module.\n *\n * @alias workbox.setConfig\n */\n setConfig(options = {}) {\n if (!this._modulesLoaded) {\n Object.assign(this._options, options);\n this._env = this._options.debug ? 'dev' : 'prod';\n } else {\n throw new Error('Config must be set before accessing workbox.* modules');\n }\n }\n\n /**\n * Load a Workbox module by passing in the appropriate module name.\n *\n * This is not generally needed unless you know there are modules that are\n * dynamically used and you want to safe guard use of the module while the\n * user may be offline.\n *\n * @param {string} moduleName\n *\n * @alias workbox.loadModule\n */\n loadModule(moduleName) {\n const modulePath = this._getImportPath(moduleName);\n try {\n importScripts(modulePath);\n this._modulesLoaded = true;\n } catch (err) {\n // TODO Add context of this error if using the CDN vs the local file.\n\n // We can't rely on workbox-core being loaded so using console\n // eslint-disable-next-line\n console.error(\n `Unable to import module '${moduleName}' from '${modulePath}'.`);\n throw err;\n }\n }\n\n /**\n * This method will get the path / CDN URL to be used for importScript calls.\n *\n * @param {string} moduleName\n * @return {string} URL to the desired module.\n *\n * @private\n */\n _getImportPath(moduleName) {\n if (this._options.modulePathCb) {\n return this._options.modulePathCb(moduleName, this._options.debug);\n }\n\n // TODO: This needs to be dynamic some how.\n let pathParts = [CDN_PATH];\n\n const fileName = `${moduleName}.${this._env}.js`;\n\n const pathPrefix = this._options.modulePathPrefix;\n if (pathPrefix) {\n // Split to avoid issues with developers ending / not ending with slash\n pathParts = pathPrefix.split('/');\n\n // We don't need a slash at the end as we will be adding\n // a filename regardless\n if (pathParts[pathParts.length - 1] === '') {\n pathParts.splice(pathParts.length - 1, 1);\n }\n }\n\n pathParts.push(fileName);\n\n return pathParts.join('/');\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxSW} from './controllers/WorkboxSW.mjs';\nimport './_version.mjs';\n\n/**\n * @namespace workbox\n */\n\n// Don't export anything, just expose a global.\nself.workbox = new WorkboxSW();\n"],"names":["self","_","e","CDN_PATH","MODULE_KEY_TO_NAME_MAPPING","backgroundSync","broadcastUpdate","cacheableResponse","core","expiration","googleAnalytics","navigationPreload","precaching","rangeRequests","routing","strategies","streams","workbox","constructor","v","_options","debug","location","hostname","modulePathPrefix","modulePathCb","_env","this","_modulesLoaded","Proxy","get","target","key","moduleName","loadModule","setConfig","options","Error","Object","assign","modulePath","_getImportPath","importScripts","err","console","error","pathParts","fileName","pathPrefix","split","length","splice","push","join"],"mappings":"yBAAA,IAAIA,KAAK,qBAAqBC,IAAI,MAAMC,ICUxC,MAAMC,EAAY,4DAEZC,EAA6B,CAKjCC,eAAgB,kBAChBC,gBAAiB,mBACjBC,kBAAmB,qBACnBC,KAAM,OACNC,WAAY,aACZC,gBAAiB,aACjBC,kBAAmB,qBACnBC,WAAY,aACZC,cAAe,iBACfC,QAAS,UACTC,WAAY,aACZC,QAAS,WCZXhB,KAAKiB,QAAU,IDqBR,MAMLC,0BACOC,EAAI,QACJC,EAAW,CACdC,MAAkC,cAA3BrB,KAAKsB,SAASC,SACrBC,iBAAkB,KAClBC,aAAc,WAGXC,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,YACrCO,GAAiB,EAEf,IAAIC,MAAMF,KAAM,CACrBG,IAAIC,EAAQC,MACND,EAAOC,UACFD,EAAOC,SAGVC,EAAa7B,EAA2B4B,UAC1CC,GACFF,EAAOG,sBAAsBD,KAGxBF,EAAOC,MAsBpBG,UAAUC,EAAU,OACbT,KAAKC,QAIF,IAAIS,MAAM,yDAHhBC,OAAOC,OAAOZ,KAAKP,EAAUgB,QACxBV,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,OAiB9Ca,WAAWD,SACHO,EAAab,KAAKc,EAAeR,OAErCS,cAAcF,QACTZ,GAAiB,EACtB,MAAOe,SAKPC,QAAQC,kCACwBZ,YAAqBO,OAC/CG,GAYVF,EAAeR,MACTN,KAAKP,EAASK,oBACTE,KAAKP,EAASK,aAAaQ,EAAYN,KAAKP,EAASC,WAI1DyB,EAAY,CAAC3C,SAEX4C,KAAcd,KAAcN,KAAKD,OAEjCsB,EAAarB,KAAKP,EAASI,wBAC7BwB,GAMsC,MAJxCF,EAAYE,EAAWC,MAAM,MAIfH,EAAUI,OAAS,IAC/BJ,EAAUK,OAAOL,EAAUI,OAAS,EAAG,GAI3CJ,EAAUM,KAAKL,GAERD,EAAUO,KAAK"}
\ No newline at end of file
try {
self['workbox:window:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Sends a data object to a service worker via `postMessage` and resolves with
* a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will not
* resolve.
*
* @param {ServiceWorker} sw The service worker to send the message to.
* @param {Object} data An object to send to the service worker.
* @return {Promise<Object|undefined>}
*
* @memberof module:workbox-window
*/
var messageSW = function messageSW(sw, data) {
return new Promise(function (resolve) {
var messageChannel = new MessageChannel();
messageChannel.port1.onmessage = function (evt) {
return resolve(evt.data);
};
sw.postMessage(data, [messageChannel.port2]);
});
};
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
try {
self['workbox:core:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The Deferred class composes Promises in a way that allows for them to be
* resolved or rejected from outside the constructor. In most cases promises
* should be used directly, but Deferreds can be necessary when the logic to
* resolve a promise must be separate.
*
* @private
*/
var Deferred =
/**
* Creates a promise and exposes its resolve and reject functions as methods.
*/
function Deferred() {
var _this = this;
this.promise = new Promise(function (resolve, reject) {
_this.resolve = resolve;
_this.reject = reject;
});
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
var logger = function () {
var inGroup = false;
var methodToColorMap = {
debug: "#7f8c8d",
// Gray
log: "#2ecc71",
// Green
warn: "#f39c12",
// Yellow
error: "#c0392b",
// Red
groupCollapsed: "#3498db",
// Blue
groupEnd: null // No colored prefix on groupEnd
};
var print = function print(method, args) {
var _console2;
if (method === 'groupCollapsed') {
// Safari doesn't print all console.groupCollapsed() arguments:
// https://bugs.webkit.org/show_bug.cgi?id=182754
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
var _console;
(_console = console)[method].apply(_console, args);
return;
}
}
var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
(_console2 = console)[method].apply(_console2, logPrefix.concat(args));
if (method === 'groupCollapsed') {
inGroup = true;
}
if (method === 'groupEnd') {
inGroup = false;
}
};
var api = {};
var _arr = Object.keys(methodToColorMap);
var _loop = function _loop() {
var method = _arr[_i];
api[method] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
print(method, args);
};
};
for (var _i = 0; _i < _arr.length; _i++) {
_loop();
}
return api;
}();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `EventTarget` shim.
* This is necessary because not all browsers support constructable
* `EventTarget`, so using a real `EventTarget` will error.
* @private
*/
var EventTargetShim =
/*#__PURE__*/
function () {
/**
* Creates an event listener registry
*
* @private
*/
function EventTargetShim() {
// A registry of event types to listeners.
this._eventListenerRegistry = {};
}
/**
* @param {string} type
* @param {Function} listener
* @private
*/
var _proto = EventTargetShim.prototype;
_proto.addEventListener = function addEventListener(type, listener) {
this._getEventListenersByType(type).add(listener);
};
/**
* @param {string} type
* @param {Function} listener
* @private
*/
_proto.removeEventListener = function removeEventListener(type, listener) {
this._getEventListenersByType(type).delete(listener);
};
/**
* @param {Event} event
* @private
*/
_proto.dispatchEvent = function dispatchEvent(event) {
event.target = this;
this._getEventListenersByType(event.type).forEach(function (listener) {
return listener(event);
});
};
/**
* Returns a Set of listeners associated with the passed event type.
* If no handlers have been registered, an empty Set is returned.
*
* @param {string} type The event type.
* @return {Set} An array of handler functions.
* @private
*/
_proto._getEventListenersByType = function _getEventListenersByType(type) {
return this._eventListenerRegistry[type] = this._eventListenerRegistry[type] || new Set();
};
return EventTargetShim;
}();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Returns true if two URLs have the same `.href` property. The URLS can be
* relative, and if they are the current location href is used to resolve URLs.
*
* @private
* @param {string} url1
* @param {string} url2
* @return {boolean}
*/
var urlsMatch = function urlsMatch(url1, url2) {
return new URL(url1, location).href === new URL(url2, location).href;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `Event` subclass shim.
* This doesn't *actually* subclass `Event` because not all browsers support
* constructable `EventTarget`, and using a real `Event` will error.
* @private
*/
var WorkboxEvent =
/**
* @param {string} type
* @param {Object} props
*/
function WorkboxEvent(type, props) {
Object.assign(this, props, {
type: type
});
};
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}
function _async(f) {
return function () {
for (var args = [], i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
}
function _invoke(body, then) {
var result = body();
if (result && result.then) {
return result.then(then);
}
return then(result);
}
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
if (!value || !value.then) {
value = Promise.resolve(value);
}
return then ? value.then(then) : value;
}
function _awaitIgnored(value, direct) {
if (!direct) {
return value && value.then ? value.then(_empty) : Promise.resolve();
}
}
function _empty() {}
// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
// chosen, but it seems to avoid false positives in my testing.
var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
// that the registration didn't trigger an update.
var REGISTRATION_TIMEOUT_DURATION = 60000;
/**
* A class to aid in handling service worker registration, updates, and
* reacting to service worker lifecycle events.
*
* @fires [message]{@link module:workbox-window.Workbox#message}
* @fires [installed]{@link module:workbox-window.Workbox#installed}
* @fires [waiting]{@link module:workbox-window.Workbox#waiting}
* @fires [controlling]{@link module:workbox-window.Workbox#controlling}
* @fires [activated]{@link module:workbox-window.Workbox#activated}
* @fires [redundant]{@link module:workbox-window.Workbox#redundant}
* @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
* @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
* @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
*
* @memberof module:workbox-window
*/
var Workbox =
/*#__PURE__*/
function (_EventTargetShim) {
_inheritsLoose(Workbox, _EventTargetShim);
/**
* Creates a new Workbox instance with a script URL and service worker
* options. The script URL and options are the same as those used when
* calling `navigator.serviceWorker.register(scriptURL, options)`. See:
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
*
* @param {string} scriptURL The service worker script associated with this
* instance.
* @param {Object} [registerOptions] The service worker options associated
* with this instance.
*/
function Workbox(scriptURL, registerOptions) {
var _this;
if (registerOptions === void 0) {
registerOptions = {};
}
_this = _EventTargetShim.call(this) || this;
_this._scriptURL = scriptURL;
_this._registerOptions = registerOptions;
_this._updateFoundCount = 0; // Deferreds we can resolve later.
_this._swDeferred = new Deferred();
_this._activeDeferred = new Deferred();
_this._controllingDeferred = new Deferred(); // Bind event handler callbacks.
_this._onMessage = _this._onMessage.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onStateChange = _this._onStateChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onUpdateFound = _this._onUpdateFound.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onControllerChange = _this._onControllerChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
/**
* Registers a service worker for this instances script URL and service
* worker options. By default this method delays registration until after
* the window has loaded.
*
* @param {Object} [options]
* @param {Function} [options.immediate=false] Setting this to true will
* register the service worker immediately, even if the window has
* not loaded (not recommended).
*/
var _proto = Workbox.prototype;
_proto.register = _async(function (_temp) {
var _this2 = this;
var _ref = _temp === void 0 ? {} : _temp,
_ref$immediate = _ref.immediate,
immediate = _ref$immediate === void 0 ? false : _ref$immediate;
{
if (_this2._registrationTime) {
logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
return;
}
}
return _invoke(function () {
if (!immediate && document.readyState !== 'complete') {
return _awaitIgnored(new Promise(function (res) {
return addEventListener('load', res);
}));
}
}, function () {
// Set this flag to true if any service worker was controlling the page
// at registration time.
_this2._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
// the page, and if that SW script (and version, if specified) matches this
// instance's script.
_this2._compatibleControllingSW = _this2._getControllingSWIfCompatible();
return _await(_this2._registerScript(), function (_this2$_registerScrip) {
_this2._registration = _this2$_registerScrip;
// If we have a compatible controller, store the controller as the "own"
// SW, resolve active/controlling deferreds and add necessary listeners.
if (_this2._compatibleControllingSW) {
_this2._sw = _this2._compatibleControllingSW;
_this2._activeDeferred.resolve(_this2._compatibleControllingSW);
_this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
_this2._reportWindowReady(_this2._compatibleControllingSW);
_this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
once: true
});
} // If there's a waiting service worker with a matching URL before the
// `updatefound` event fires, it likely means that this site is open
// in another tab, or the user refreshed the page (and thus the prevoius
// page wasn't fully unloaded before this page started loading).
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
var waitingSW = _this2._registration.waiting;
if (waitingSW && urlsMatch(waitingSW.scriptURL, _this2._scriptURL)) {
// Store the waiting SW as the "own" Sw, even if it means overwriting
// a compatible controller.
_this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
// listener after awaiting `register()` will get this event.
Promise.resolve().then(function () {
_this2.dispatchEvent(new WorkboxEvent('waiting', {
sw: waitingSW,
wasWaitingBeforeRegister: true
}));
{
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
}
});
} // If an "own" SW is already set, resolve the deferred.
if (_this2._sw) {
_this2._swDeferred.resolve(_this2._sw);
}
{
logger.log('Successfully registered service worker.', _this2._scriptURL);
if (navigator.serviceWorker.controller) {
if (_this2._compatibleControllingSW) {
logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
} else {
logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
}
}
var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
var scopeURL = new URL(_this2._registerOptions.scope || _this2._scriptURL, document.baseURI);
var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
return !location.pathname.startsWith(scopeURLBasePath);
};
if (currentPageIsOutOfScope()) {
logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
}
}
_this2._registration.addEventListener('updatefound', _this2._onUpdateFound);
navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
once: true
}); // Add message listeners.
if ('BroadcastChannel' in self) {
_this2._broadcastChannel = new BroadcastChannel('workbox');
_this2._broadcastChannel.addEventListener('message', _this2._onMessage);
}
navigator.serviceWorker.addEventListener('message', _this2._onMessage);
return _this2._registration;
});
});
});
/**
* Resolves to the service worker registered by this instance as soon as it
* is active. If a service worker was already controlling at registration
* time then it will resolve to that if the script URLs (and optionally
* script versions) match, otherwise it will wait until an update is found
* and activates.
*
* @return {Promise<ServiceWorker>}
*/
/**
* Resolves with a reference to a service worker that matches the script URL
* of this instance, as soon as it's available.
*
* If, at registration time, there's already an active or waiting service
* worker with a matching script URL, it will be used (with the waiting
* service worker taking precedence over the active service worker if both
* match, since the waiting service worker would have been registered more
* recently).
* If there's no matching active or waiting service worker at registration
* time then the promise will not resolve until an update is found and starts
* installing, at which point the installing service worker is used.
*
* @return {Promise<ServiceWorker>}
*/
_proto.getSW = _async(function () {
var _this3 = this;
// If `this._sw` is set, resolve with that as we want `getSW()` to
// return the correct (new) service worker if an update is found.
return _this3._sw || _this3._swDeferred.promise;
});
/**
* Sends the passed data object to the service worker registered by this
* instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
* with a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will never
* resolve.
*
* @param {Object} data An object to send to the service worker
* @return {Promise<Object>}
*/
_proto.messageSW = _async(function (data) {
var _this4 = this;
return _await(_this4.getSW(), function (sw) {
return messageSW(sw, data);
});
});
/**
* Checks for a service worker already controlling the page and returns
* it if its script URL matchs.
*
* @private
* @return {ServiceWorker|undefined}
*/
_proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
var controller = navigator.serviceWorker.controller;
if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
return controller;
}
};
/**
* Registers a service worker for this instances script URL and register
* options and tracks the time registration was complete.
*
* @private
*/
_proto._registerScript = _async(function () {
var _this5 = this;
return _catch(function () {
return _await(navigator.serviceWorker.register(_this5._scriptURL, _this5._registerOptions), function (reg) {
// Keep track of when registration happened, so it can be used in the
// `this._onUpdateFound` heuristic. Also use the presence of this
// property as a way to see if `.register()` has been called.
_this5._registrationTime = performance.now();
return reg;
});
}, function (error) {
{
logger.error(error);
} // Re-throw the error.
throw error;
});
});
/**
* Sends a message to the passed service worker that the window is ready.
*
* @param {ServiceWorker} sw
* @private
*/
_proto._reportWindowReady = function _reportWindowReady(sw) {
messageSW(sw, {
type: 'WINDOW_READY',
meta: 'workbox-window'
});
};
/**
* @private
*/
_proto._onUpdateFound = function _onUpdateFound() {
var installingSW = this._registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
// different from the current controlling SW's script URL, we know any
// successful registration calls will trigger an `updatefound` event.
// But if the registered script URL is the same as the current controlling
// SW's script URL, we'll only get an `updatefound` event if the file
// changed since it was last registered. This can be a problem if the user
// opens up the same page in a different tab, and that page registers
// a SW that triggers an update. It's a problem because this page has no
// good way of knowing whether the `updatefound` event came from the SW
// script it registered or from a registration attempt made by a newer
// version of the page running in another tab.
// To minimize the possibility of a false positive, we use the logic here:
var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
// add the `updatefound` event listener until the `register()` call, if
// `_updateFoundCount` is > 0 then it means this method has already
// been called, thus this SW must be external
this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
// instance's script URL, we know it's definitely not from our
// registration.
!urlsMatch(installingSW.scriptURL, this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
// Any `updatefound` event that occurs long after our registration is
// assumed to be external.
performance.now() > this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
// triggered by this instance.
true : false;
if (updateLikelyTriggeredExternally) {
this._externalSW = installingSW;
this._registration.removeEventListener('updatefound', this._onUpdateFound);
} else {
// If the update was not triggered externally we know the installing
// SW is the one we registered, so we set it.
this._sw = installingSW;
this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
// callback for, but we do log messages for it in development.
{
if (navigator.serviceWorker.controller) {
logger.log('Updated service worker found. Installing now...');
} else {
logger.log('Service worker is installing...');
}
}
} // Increment the `updatefound` count, so future invocations of this
// method can be sure they were triggered externally.
++this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
// triggered externally, since we have callbacks for both.
installingSW.addEventListener('statechange', this._onStateChange);
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onStateChange = function _onStateChange(originalEvent) {
var _this6 = this;
var sw = originalEvent.target;
var state = sw.state;
var isExternal = sw === this._externalSW;
var eventPrefix = isExternal ? 'external' : '';
var eventProps = {
sw: sw,
originalEvent: originalEvent
};
if (!isExternal && this._isUpdate) {
eventProps.isUpdate = true;
}
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
if (state === 'installed') {
// This timeout is used to ignore cases where the service worker calls
// `skipWaiting()` in the install event, thus moving it directly in the
// activating state. (Since all service workers *must* go through the
// waiting phase, the only way to detect `skipWaiting()` called in the
// install event is to observe that the time spent in the waiting phase
// is very short.)
// NOTE: we don't need separate timeouts for the own and external SWs
// since they can't go through these phases at the same time.
this._waitingTimeout = setTimeout(function () {
// Ensure the SW is still waiting (it may now be redundant).
if (state === 'installed' && _this6._registration.waiting === sw) {
_this6.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
{
if (isExternal) {
logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
} else {
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
}
}
}
}, WAITING_TIMEOUT_DURATION);
} else if (state === 'activating') {
clearTimeout(this._waitingTimeout);
if (!isExternal) {
this._activeDeferred.resolve(sw);
}
}
{
switch (state) {
case 'installed':
if (isExternal) {
logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
} else {
logger.log('Registered service worker installed.');
}
break;
case 'activated':
if (isExternal) {
logger.warn('An external service worker has activated.');
} else {
logger.log('Registered service worker activated.');
if (sw !== navigator.serviceWorker.controller) {
logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
}
}
break;
case 'redundant':
if (sw === this._compatibleControllingSW) {
logger.log('Previously controlling service worker now redundant!');
} else if (!isExternal) {
logger.log('Registered service worker now redundant!');
}
break;
}
}
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onControllerChange = function _onControllerChange(originalEvent) {
var sw = this._sw;
if (sw === navigator.serviceWorker.controller) {
this.dispatchEvent(new WorkboxEvent('controlling', {
sw: sw,
originalEvent: originalEvent
}));
{
logger.log('Registered service worker now controlling this page.');
}
this._controllingDeferred.resolve(sw);
}
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onMessage = function _onMessage(originalEvent) {
var data = originalEvent.data;
this.dispatchEvent(new WorkboxEvent('message', {
data: data,
originalEvent: originalEvent
}));
};
_createClass(Workbox, [{
key: "active",
get: function get() {
return this._activeDeferred.promise;
}
/**
* Resolves to the service worker registered by this instance as soon as it
* is controlling the page. If a service worker was already controlling at
* registration time then it will resolve to that if the script URLs (and
* optionally script versions) match, otherwise it will wait until an update
* is found and starts controlling the page.
* Note: the first time a service worker is installed it will active but
* not start controlling the page unless `clients.claim()` is called in the
* service worker.
*
* @return {Promise<ServiceWorker>}
*/
}, {
key: "controlling",
get: function get() {
return this._controllingDeferred.promise;
}
}]);
return Workbox;
}(EventTargetShim); // The jsdoc comments below outline the events this instance may dispatch:
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
export { Workbox, messageSW };
//# sourceMappingURL=workbox-window.dev.es5.mjs.map
{"version":3,"file":"workbox-window.dev.es5.mjs","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../../workbox-core/_private/logger.mjs","../utils/EventTargetShim.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst logger = process.env.NODE_ENV === 'production' ? null : (() => {\n let inGroup = false;\n\n const methodToColorMap = {\n debug: `#7f8c8d`, // Gray\n log: `#2ecc71`, // Green\n warn: `#f39c12`, // Yellow\n error: `#c0392b`, // Red\n groupCollapsed: `#3498db`, // Blue\n groupEnd: null, // No colored prefix on groupEnd\n };\n\n const print = function(method, args) {\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n\n console[method](...logPrefix, ...args);\n\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n\n const api = {};\n for (const method of Object.keys(methodToColorMap)) {\n api[method] = (...args) => {\n print(method, args);\n };\n }\n\n return api;\n})();\n\nexport {logger};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messageSW} from './messageSW.mjs';\nimport {Workbox} from './Workbox.mjs';\nimport './_version.mjs';\n\n\n/**\n * @module workbox-window\n */\nexport {\n Workbox,\n messageSW,\n};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","promise","reject","logger","process","inGroup","methodToColorMap","debug","log","warn","error","groupCollapsed","groupEnd","print","method","args","test","navigator","userAgent","console","styles","logPrefix","join","api","Object","keys","EventTargetShim","_eventListenerRegistry","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","event","target","forEach","Set","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","props","assign","body","recover","result","then","f","i","arguments","length","apply","value","direct","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","register","immediate","_registrationTime","document","readyState","res","_isUpdate","Boolean","serviceWorker","controller","_compatibleControllingSW","_getControllingSWIfCompatible","_registerScript","_registration","_sw","_reportWindowReady","once","waitingSW","waiting","wasWaitingBeforeRegister","currentPageIsOutOfScope","scopeURL","scope","baseURI","scopeURLBasePath","pathname","startsWith","_broadcastChannel","BroadcastChannel","getSW","reg","performance","now","meta","installingSW","installing","updateLikelyTriggeredExternally","_externalSW","originalEvent","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","clearTimeout"],"mappings":"AAAA,IAAG;EAACA,IAAI,CAAC,sBAAD,CAAJ,IAA8BC,CAAC,EAA/B;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G,KAAKqG,GAAhB;;QACIrG,EAAE,KAAK4B,SAAS,CAACmE,aAAV,CAAwBC,UAAnC,EAA+C;WACxClD,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,aAAjB,EAAgC;QAACzD,EAAE,EAAFA,EAAD;QAAK6H,aAAa,EAAbA;OAArC,CAAnB;;MAC2C;QACzC/G,MAAM,CAACK,GAAP,CAAW,sDAAX;;;WAEG8D,oBAAL,CAA0B9E,OAA1B,CAAkCH,EAAlC;;;;;;;;;SAQJkF,iCAAW2C,eAAe;QACjB5H,IADiB,GACT4H,aADS,CACjB5H,IADiB;SAEnB6C,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,SAAjB,EAA4B;MAACxD,IAAI,EAAJA,IAAD;MAAO4H,aAAa,EAAbA;KAAnC,CAAnB;;;;;wBA7RW;aACJ,KAAK7C,eAAL,CAAqBpE,OAA5B;;;;;;;;;;;;;;;;;wBAegB;aACT,KAAKqE,oBAAL,CAA0BrE,OAAjC;;;;;EA7KkByB;;AC1CtB;;;;;;;;;;"}
\ No newline at end of file
try {
self['workbox:window:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Sends a data object to a service worker via `postMessage` and resolves with
* a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will not
* resolve.
*
* @param {ServiceWorker} sw The service worker to send the message to.
* @param {Object} data An object to send to the service worker.
* @return {Promise<Object|undefined>}
*
* @memberof module:workbox-window
*/
const messageSW = (sw, data) => {
return new Promise(resolve => {
let messageChannel = new MessageChannel();
messageChannel.port1.onmessage = evt => resolve(evt.data);
sw.postMessage(data, [messageChannel.port2]);
});
};
try {
self['workbox:core:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The Deferred class composes Promises in a way that allows for them to be
* resolved or rejected from outside the constructor. In most cases promises
* should be used directly, but Deferreds can be necessary when the logic to
* resolve a promise must be separate.
*
* @private
*/
class Deferred {
/**
* Creates a promise and exposes its resolve and reject functions as methods.
*/
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const logger = (() => {
let inGroup = false;
const methodToColorMap = {
debug: `#7f8c8d`,
// Gray
log: `#2ecc71`,
// Green
warn: `#f39c12`,
// Yellow
error: `#c0392b`,
// Red
groupCollapsed: `#3498db`,
// Blue
groupEnd: null // No colored prefix on groupEnd
};
const print = function (method, args) {
if (method === 'groupCollapsed') {
// Safari doesn't print all console.groupCollapsed() arguments:
// https://bugs.webkit.org/show_bug.cgi?id=182754
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
console[method](...args);
return;
}
}
const styles = [`background: ${methodToColorMap[method]}`, `border-radius: 0.5em`, `color: white`, `font-weight: bold`, `padding: 2px 0.5em`]; // When in a group, the workbox prefix is not displayed.
const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
console[method](...logPrefix, ...args);
if (method === 'groupCollapsed') {
inGroup = true;
}
if (method === 'groupEnd') {
inGroup = false;
}
};
const api = {};
for (const method of Object.keys(methodToColorMap)) {
api[method] = (...args) => {
print(method, args);
};
}
return api;
})();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `EventTarget` shim.
* This is necessary because not all browsers support constructable
* `EventTarget`, so using a real `EventTarget` will error.
* @private
*/
class EventTargetShim {
/**
* Creates an event listener registry
*
* @private
*/
constructor() {
// A registry of event types to listeners.
this._eventListenerRegistry = {};
}
/**
* @param {string} type
* @param {Function} listener
* @private
*/
addEventListener(type, listener) {
this._getEventListenersByType(type).add(listener);
}
/**
* @param {string} type
* @param {Function} listener
* @private
*/
removeEventListener(type, listener) {
this._getEventListenersByType(type).delete(listener);
}
/**
* @param {Event} event
* @private
*/
dispatchEvent(event) {
event.target = this;
this._getEventListenersByType(event.type).forEach(listener => listener(event));
}
/**
* Returns a Set of listeners associated with the passed event type.
* If no handlers have been registered, an empty Set is returned.
*
* @param {string} type The event type.
* @return {Set} An array of handler functions.
* @private
*/
_getEventListenersByType(type) {
return this._eventListenerRegistry[type] = this._eventListenerRegistry[type] || new Set();
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Returns true if two URLs have the same `.href` property. The URLS can be
* relative, and if they are the current location href is used to resolve URLs.
*
* @private
* @param {string} url1
* @param {string} url2
* @return {boolean}
*/
const urlsMatch = (url1, url2) => {
return new URL(url1, location).href === new URL(url2, location).href;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `Event` subclass shim.
* This doesn't *actually* subclass `Event` because not all browsers support
* constructable `EventTarget`, and using a real `Event` will error.
* @private
*/
class WorkboxEvent {
/**
* @param {string} type
* @param {Object} props
*/
constructor(type, props) {
Object.assign(this, props, {
type
});
}
}
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
// chosen, but it seems to avoid false positives in my testing.
const WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
// that the registration didn't trigger an update.
const REGISTRATION_TIMEOUT_DURATION = 60000;
/**
* A class to aid in handling service worker registration, updates, and
* reacting to service worker lifecycle events.
*
* @fires [message]{@link module:workbox-window.Workbox#message}
* @fires [installed]{@link module:workbox-window.Workbox#installed}
* @fires [waiting]{@link module:workbox-window.Workbox#waiting}
* @fires [controlling]{@link module:workbox-window.Workbox#controlling}
* @fires [activated]{@link module:workbox-window.Workbox#activated}
* @fires [redundant]{@link module:workbox-window.Workbox#redundant}
* @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
* @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
* @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
*
* @memberof module:workbox-window
*/
class Workbox extends EventTargetShim {
/**
* Creates a new Workbox instance with a script URL and service worker
* options. The script URL and options are the same as those used when
* calling `navigator.serviceWorker.register(scriptURL, options)`. See:
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
*
* @param {string} scriptURL The service worker script associated with this
* instance.
* @param {Object} [registerOptions] The service worker options associated
* with this instance.
*/
constructor(scriptURL, registerOptions = {}) {
super();
this._scriptURL = scriptURL;
this._registerOptions = registerOptions;
this._updateFoundCount = 0; // Deferreds we can resolve later.
this._swDeferred = new Deferred();
this._activeDeferred = new Deferred();
this._controllingDeferred = new Deferred(); // Bind event handler callbacks.
this._onMessage = this._onMessage.bind(this);
this._onStateChange = this._onStateChange.bind(this);
this._onUpdateFound = this._onUpdateFound.bind(this);
this._onControllerChange = this._onControllerChange.bind(this);
}
/**
* Registers a service worker for this instances script URL and service
* worker options. By default this method delays registration until after
* the window has loaded.
*
* @param {Object} [options]
* @param {Function} [options.immediate=false] Setting this to true will
* register the service worker immediately, even if the window has
* not loaded (not recommended).
*/
async register({
immediate = false
} = {}) {
{
if (this._registrationTime) {
logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
return;
}
}
if (!immediate && document.readyState !== 'complete') {
await new Promise(res => addEventListener('load', res));
} // Set this flag to true if any service worker was controlling the page
// at registration time.
this._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
// the page, and if that SW script (and version, if specified) matches this
// instance's script.
this._compatibleControllingSW = this._getControllingSWIfCompatible();
this._registration = await this._registerScript(); // If we have a compatible controller, store the controller as the "own"
// SW, resolve active/controlling deferreds and add necessary listeners.
if (this._compatibleControllingSW) {
this._sw = this._compatibleControllingSW;
this._activeDeferred.resolve(this._compatibleControllingSW);
this._controllingDeferred.resolve(this._compatibleControllingSW);
this._reportWindowReady(this._compatibleControllingSW);
this._compatibleControllingSW.addEventListener('statechange', this._onStateChange, {
once: true
});
} // If there's a waiting service worker with a matching URL before the
// `updatefound` event fires, it likely means that this site is open
// in another tab, or the user refreshed the page (and thus the prevoius
// page wasn't fully unloaded before this page started loading).
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
const waitingSW = this._registration.waiting;
if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {
// Store the waiting SW as the "own" Sw, even if it means overwriting
// a compatible controller.
this._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
// listener after awaiting `register()` will get this event.
Promise.resolve().then(() => {
this.dispatchEvent(new WorkboxEvent('waiting', {
sw: waitingSW,
wasWaitingBeforeRegister: true
}));
{
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
}
});
} // If an "own" SW is already set, resolve the deferred.
if (this._sw) {
this._swDeferred.resolve(this._sw);
}
{
logger.log('Successfully registered service worker.', this._scriptURL);
if (navigator.serviceWorker.controller) {
if (this._compatibleControllingSW) {
logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
} else {
logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
}
}
const currentPageIsOutOfScope = () => {
const scopeURL = new URL(this._registerOptions.scope || this._scriptURL, document.baseURI);
const scopeURLBasePath = new URL('./', scopeURL.href).pathname;
return !location.pathname.startsWith(scopeURLBasePath);
};
if (currentPageIsOutOfScope()) {
logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
}
}
this._registration.addEventListener('updatefound', this._onUpdateFound);
navigator.serviceWorker.addEventListener('controllerchange', this._onControllerChange, {
once: true
}); // Add message listeners.
if ('BroadcastChannel' in self) {
this._broadcastChannel = new BroadcastChannel('workbox');
this._broadcastChannel.addEventListener('message', this._onMessage);
}
navigator.serviceWorker.addEventListener('message', this._onMessage);
return this._registration;
}
/**
* Resolves to the service worker registered by this instance as soon as it
* is active. If a service worker was already controlling at registration
* time then it will resolve to that if the script URLs (and optionally
* script versions) match, otherwise it will wait until an update is found
* and activates.
*
* @return {Promise<ServiceWorker>}
*/
get active() {
return this._activeDeferred.promise;
}
/**
* Resolves to the service worker registered by this instance as soon as it
* is controlling the page. If a service worker was already controlling at
* registration time then it will resolve to that if the script URLs (and
* optionally script versions) match, otherwise it will wait until an update
* is found and starts controlling the page.
* Note: the first time a service worker is installed it will active but
* not start controlling the page unless `clients.claim()` is called in the
* service worker.
*
* @return {Promise<ServiceWorker>}
*/
get controlling() {
return this._controllingDeferred.promise;
}
/**
* Resolves with a reference to a service worker that matches the script URL
* of this instance, as soon as it's available.
*
* If, at registration time, there's already an active or waiting service
* worker with a matching script URL, it will be used (with the waiting
* service worker taking precedence over the active service worker if both
* match, since the waiting service worker would have been registered more
* recently).
* If there's no matching active or waiting service worker at registration
* time then the promise will not resolve until an update is found and starts
* installing, at which point the installing service worker is used.
*
* @return {Promise<ServiceWorker>}
*/
async getSW() {
// If `this._sw` is set, resolve with that as we want `getSW()` to
// return the correct (new) service worker if an update is found.
return this._sw || this._swDeferred.promise;
}
/**
* Sends the passed data object to the service worker registered by this
* instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
* with a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will never
* resolve.
*
* @param {Object} data An object to send to the service worker
* @return {Promise<Object>}
*/
async messageSW(data) {
const sw = await this.getSW();
return messageSW(sw, data);
}
/**
* Checks for a service worker already controlling the page and returns
* it if its script URL matchs.
*
* @private
* @return {ServiceWorker|undefined}
*/
_getControllingSWIfCompatible() {
const controller = navigator.serviceWorker.controller;
if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
return controller;
}
}
/**
* Registers a service worker for this instances script URL and register
* options and tracks the time registration was complete.
*
* @private
*/
async _registerScript() {
try {
const reg = await navigator.serviceWorker.register(this._scriptURL, this._registerOptions); // Keep track of when registration happened, so it can be used in the
// `this._onUpdateFound` heuristic. Also use the presence of this
// property as a way to see if `.register()` has been called.
this._registrationTime = performance.now();
return reg;
} catch (error) {
{
logger.error(error);
} // Re-throw the error.
throw error;
}
}
/**
* Sends a message to the passed service worker that the window is ready.
*
* @param {ServiceWorker} sw
* @private
*/
_reportWindowReady(sw) {
messageSW(sw, {
type: 'WINDOW_READY',
meta: 'workbox-window'
});
}
/**
* @private
*/
_onUpdateFound() {
const installingSW = this._registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
// different from the current controlling SW's script URL, we know any
// successful registration calls will trigger an `updatefound` event.
// But if the registered script URL is the same as the current controlling
// SW's script URL, we'll only get an `updatefound` event if the file
// changed since it was last registered. This can be a problem if the user
// opens up the same page in a different tab, and that page registers
// a SW that triggers an update. It's a problem because this page has no
// good way of knowing whether the `updatefound` event came from the SW
// script it registered or from a registration attempt made by a newer
// version of the page running in another tab.
// To minimize the possibility of a false positive, we use the logic here:
let updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
// add the `updatefound` event listener until the `register()` call, if
// `_updateFoundCount` is > 0 then it means this method has already
// been called, thus this SW must be external
this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
// instance's script URL, we know it's definitely not from our
// registration.
!urlsMatch(installingSW.scriptURL, this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
// Any `updatefound` event that occurs long after our registration is
// assumed to be external.
performance.now() > this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
// triggered by this instance.
true : false;
if (updateLikelyTriggeredExternally) {
this._externalSW = installingSW;
this._registration.removeEventListener('updatefound', this._onUpdateFound);
} else {
// If the update was not triggered externally we know the installing
// SW is the one we registered, so we set it.
this._sw = installingSW;
this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
// callback for, but we do log messages for it in development.
{
if (navigator.serviceWorker.controller) {
logger.log('Updated service worker found. Installing now...');
} else {
logger.log('Service worker is installing...');
}
}
} // Increment the `updatefound` count, so future invocations of this
// method can be sure they were triggered externally.
++this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
// triggered externally, since we have callbacks for both.
installingSW.addEventListener('statechange', this._onStateChange);
}
/**
* @private
* @param {Event} originalEvent
*/
_onStateChange(originalEvent) {
const sw = originalEvent.target;
const {
state
} = sw;
const isExternal = sw === this._externalSW;
const eventPrefix = isExternal ? 'external' : '';
const eventProps = {
sw,
originalEvent
};
if (!isExternal && this._isUpdate) {
eventProps.isUpdate = true;
}
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
if (state === 'installed') {
// This timeout is used to ignore cases where the service worker calls
// `skipWaiting()` in the install event, thus moving it directly in the
// activating state. (Since all service workers *must* go through the
// waiting phase, the only way to detect `skipWaiting()` called in the
// install event is to observe that the time spent in the waiting phase
// is very short.)
// NOTE: we don't need separate timeouts for the own and external SWs
// since they can't go through these phases at the same time.
this._waitingTimeout = setTimeout(() => {
// Ensure the SW is still waiting (it may now be redundant).
if (state === 'installed' && this._registration.waiting === sw) {
this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
{
if (isExternal) {
logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
} else {
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
}
}
}
}, WAITING_TIMEOUT_DURATION);
} else if (state === 'activating') {
clearTimeout(this._waitingTimeout);
if (!isExternal) {
this._activeDeferred.resolve(sw);
}
}
{
switch (state) {
case 'installed':
if (isExternal) {
logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
} else {
logger.log('Registered service worker installed.');
}
break;
case 'activated':
if (isExternal) {
logger.warn('An external service worker has activated.');
} else {
logger.log('Registered service worker activated.');
if (sw !== navigator.serviceWorker.controller) {
logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
}
}
break;
case 'redundant':
if (sw === this._compatibleControllingSW) {
logger.log('Previously controlling service worker now redundant!');
} else if (!isExternal) {
logger.log('Registered service worker now redundant!');
}
break;
}
}
}
/**
* @private
* @param {Event} originalEvent
*/
_onControllerChange(originalEvent) {
const sw = this._sw;
if (sw === navigator.serviceWorker.controller) {
this.dispatchEvent(new WorkboxEvent('controlling', {
sw,
originalEvent
}));
{
logger.log('Registered service worker now controlling this page.');
}
this._controllingDeferred.resolve(sw);
}
}
/**
* @private
* @param {Event} originalEvent
*/
_onMessage(originalEvent) {
const {
data
} = originalEvent;
this.dispatchEvent(new WorkboxEvent('message', {
data,
originalEvent
}));
}
} // The jsdoc comments below outline the events this instance may dispatch:
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
export { Workbox, messageSW };
//# sourceMappingURL=workbox-window.dev.mjs.map
{"version":3,"file":"workbox-window.dev.mjs","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../../workbox-core/_private/logger.mjs","../utils/EventTargetShim.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst logger = process.env.NODE_ENV === 'production' ? null : (() => {\n let inGroup = false;\n\n const methodToColorMap = {\n debug: `#7f8c8d`, // Gray\n log: `#2ecc71`, // Green\n warn: `#f39c12`, // Yellow\n error: `#c0392b`, // Red\n groupCollapsed: `#3498db`, // Blue\n groupEnd: null, // No colored prefix on groupEnd\n };\n\n const print = function(method, args) {\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n\n console[method](...logPrefix, ...args);\n\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n\n const api = {};\n for (const method of Object.keys(methodToColorMap)) {\n api[method] = (...args) => {\n print(method, args);\n };\n }\n\n return api;\n})();\n\nexport {logger};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messageSW} from './messageSW.mjs';\nimport {Workbox} from './Workbox.mjs';\nimport './_version.mjs';\n\n\n/**\n * @module workbox-window\n */\nexport {\n Workbox,\n messageSW,\n};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","constructor","promise","reject","logger","process","inGroup","methodToColorMap","debug","log","warn","error","groupCollapsed","groupEnd","print","method","args","test","navigator","userAgent","console","styles","logPrefix","join","api","Object","keys","EventTargetShim","_eventListenerRegistry","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","event","target","forEach","Set","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","props","assign","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","register","immediate","_registrationTime","document","readyState","res","_isUpdate","Boolean","serviceWorker","controller","_compatibleControllingSW","_getControllingSWIfCompatible","_registration","_registerScript","_sw","_reportWindowReady","once","waitingSW","waiting","then","wasWaitingBeforeRegister","currentPageIsOutOfScope","scopeURL","scope","baseURI","scopeURLBasePath","pathname","startsWith","_broadcastChannel","BroadcastChannel","active","controlling","getSW","reg","performance","now","meta","installingSW","installing","updateLikelyTriggeredExternally","_externalSW","originalEvent","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","clearTimeout"],"mappings":"AAAA,IAAG;EAACA,IAAI,CAAC,sBAAD,CAAJ,IAA8BC,CAAC,EAA/B;CAAJ,CAAsC,OAAMC,CAAN,EAAQ;;ACA9C;;;;;;;AA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EAA+C;WACxCvC,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,aAAjB,EAAgC;QAAC1D,EAAD;QAAKsH;OAArC,CAAnB;;MAC2C;QACzCvG,MAAM,CAACK,GAAP,CAAW,sDAAX;;;WAEGmD,oBAAL,CAA0BpE,OAA1B,CAAkCH,EAAlC;;;;;;;;;EAQJwE,UAAU,CAAC8C,aAAD,EAAgB;UAClB;MAACrH;QAAQqH,aAAf;SACKvE,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,SAAjB,EAA4B;MAACzD,IAAD;MAAOqH;KAAnC,CAAnB;;;;;ACneJ;;;;;;;;;;"}
\ No newline at end of file
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.workbox = {}));
}(this, function (exports) { 'use strict';
try {
self['workbox:window:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Sends a data object to a service worker via `postMessage` and resolves with
* a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will not
* resolve.
*
* @param {ServiceWorker} sw The service worker to send the message to.
* @param {Object} data An object to send to the service worker.
* @return {Promise<Object|undefined>}
*
* @memberof module:workbox-window
*/
var messageSW = function messageSW(sw, data) {
return new Promise(function (resolve) {
var messageChannel = new MessageChannel();
messageChannel.port1.onmessage = function (evt) {
return resolve(evt.data);
};
sw.postMessage(data, [messageChannel.port2]);
});
};
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
try {
self['workbox:core:4.3.1'] && _();
} catch (e) {} // eslint-disable-line
/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* The Deferred class composes Promises in a way that allows for them to be
* resolved or rejected from outside the constructor. In most cases promises
* should be used directly, but Deferreds can be necessary when the logic to
* resolve a promise must be separate.
*
* @private
*/
var Deferred =
/**
* Creates a promise and exposes its resolve and reject functions as methods.
*/
function Deferred() {
var _this = this;
this.promise = new Promise(function (resolve, reject) {
_this.resolve = resolve;
_this.reject = reject;
});
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
var logger = function () {
var inGroup = false;
var methodToColorMap = {
debug: "#7f8c8d",
// Gray
log: "#2ecc71",
// Green
warn: "#f39c12",
// Yellow
error: "#c0392b",
// Red
groupCollapsed: "#3498db",
// Blue
groupEnd: null // No colored prefix on groupEnd
};
var print = function print(method, args) {
var _console2;
if (method === 'groupCollapsed') {
// Safari doesn't print all console.groupCollapsed() arguments:
// https://bugs.webkit.org/show_bug.cgi?id=182754
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
var _console;
(_console = console)[method].apply(_console, args);
return;
}
}
var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
(_console2 = console)[method].apply(_console2, logPrefix.concat(args));
if (method === 'groupCollapsed') {
inGroup = true;
}
if (method === 'groupEnd') {
inGroup = false;
}
};
var api = {};
var _arr = Object.keys(methodToColorMap);
var _loop = function _loop() {
var method = _arr[_i];
api[method] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
print(method, args);
};
};
for (var _i = 0; _i < _arr.length; _i++) {
_loop();
}
return api;
}();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `EventTarget` shim.
* This is necessary because not all browsers support constructable
* `EventTarget`, so using a real `EventTarget` will error.
* @private
*/
var EventTargetShim =
/*#__PURE__*/
function () {
/**
* Creates an event listener registry
*
* @private
*/
function EventTargetShim() {
// A registry of event types to listeners.
this._eventListenerRegistry = {};
}
/**
* @param {string} type
* @param {Function} listener
* @private
*/
var _proto = EventTargetShim.prototype;
_proto.addEventListener = function addEventListener(type, listener) {
this._getEventListenersByType(type).add(listener);
};
/**
* @param {string} type
* @param {Function} listener
* @private
*/
_proto.removeEventListener = function removeEventListener(type, listener) {
this._getEventListenersByType(type).delete(listener);
};
/**
* @param {Event} event
* @private
*/
_proto.dispatchEvent = function dispatchEvent(event) {
event.target = this;
this._getEventListenersByType(event.type).forEach(function (listener) {
return listener(event);
});
};
/**
* Returns a Set of listeners associated with the passed event type.
* If no handlers have been registered, an empty Set is returned.
*
* @param {string} type The event type.
* @return {Set} An array of handler functions.
* @private
*/
_proto._getEventListenersByType = function _getEventListenersByType(type) {
return this._eventListenerRegistry[type] = this._eventListenerRegistry[type] || new Set();
};
return EventTargetShim;
}();
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* Returns true if two URLs have the same `.href` property. The URLS can be
* relative, and if they are the current location href is used to resolve URLs.
*
* @private
* @param {string} url1
* @param {string} url2
* @return {boolean}
*/
var urlsMatch = function urlsMatch(url1, url2) {
return new URL(url1, location).href === new URL(url2, location).href;
};
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
/**
* A minimal `Event` subclass shim.
* This doesn't *actually* subclass `Event` because not all browsers support
* constructable `EventTarget`, and using a real `Event` will error.
* @private
*/
var WorkboxEvent =
/**
* @param {string} type
* @param {Object} props
*/
function WorkboxEvent(type, props) {
Object.assign(this, props, {
type: type
});
};
function _catch(body, recover) {
try {
var result = body();
} catch (e) {
return recover(e);
}
if (result && result.then) {
return result.then(void 0, recover);
}
return result;
}
function _async(f) {
return function () {
for (var args = [], i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
try {
return Promise.resolve(f.apply(this, args));
} catch (e) {
return Promise.reject(e);
}
};
}
function _invoke(body, then) {
var result = body();
if (result && result.then) {
return result.then(then);
}
return then(result);
}
function _await(value, then, direct) {
if (direct) {
return then ? then(value) : value;
}
if (!value || !value.then) {
value = Promise.resolve(value);
}
return then ? value.then(then) : value;
}
function _awaitIgnored(value, direct) {
if (!direct) {
return value && value.then ? value.then(_empty) : Promise.resolve();
}
}
function _empty() {}
// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
// chosen, but it seems to avoid false positives in my testing.
var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
// that the registration didn't trigger an update.
var REGISTRATION_TIMEOUT_DURATION = 60000;
/**
* A class to aid in handling service worker registration, updates, and
* reacting to service worker lifecycle events.
*
* @fires [message]{@link module:workbox-window.Workbox#message}
* @fires [installed]{@link module:workbox-window.Workbox#installed}
* @fires [waiting]{@link module:workbox-window.Workbox#waiting}
* @fires [controlling]{@link module:workbox-window.Workbox#controlling}
* @fires [activated]{@link module:workbox-window.Workbox#activated}
* @fires [redundant]{@link module:workbox-window.Workbox#redundant}
* @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
* @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
* @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
*
* @memberof module:workbox-window
*/
var Workbox =
/*#__PURE__*/
function (_EventTargetShim) {
_inheritsLoose(Workbox, _EventTargetShim);
/**
* Creates a new Workbox instance with a script URL and service worker
* options. The script URL and options are the same as those used when
* calling `navigator.serviceWorker.register(scriptURL, options)`. See:
* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
*
* @param {string} scriptURL The service worker script associated with this
* instance.
* @param {Object} [registerOptions] The service worker options associated
* with this instance.
*/
function Workbox(scriptURL, registerOptions) {
var _this;
if (registerOptions === void 0) {
registerOptions = {};
}
_this = _EventTargetShim.call(this) || this;
_this._scriptURL = scriptURL;
_this._registerOptions = registerOptions;
_this._updateFoundCount = 0; // Deferreds we can resolve later.
_this._swDeferred = new Deferred();
_this._activeDeferred = new Deferred();
_this._controllingDeferred = new Deferred(); // Bind event handler callbacks.
_this._onMessage = _this._onMessage.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onStateChange = _this._onStateChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onUpdateFound = _this._onUpdateFound.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this._onControllerChange = _this._onControllerChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
/**
* Registers a service worker for this instances script URL and service
* worker options. By default this method delays registration until after
* the window has loaded.
*
* @param {Object} [options]
* @param {Function} [options.immediate=false] Setting this to true will
* register the service worker immediately, even if the window has
* not loaded (not recommended).
*/
var _proto = Workbox.prototype;
_proto.register = _async(function (_temp) {
var _this2 = this;
var _ref = _temp === void 0 ? {} : _temp,
_ref$immediate = _ref.immediate,
immediate = _ref$immediate === void 0 ? false : _ref$immediate;
{
if (_this2._registrationTime) {
logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
return;
}
}
return _invoke(function () {
if (!immediate && document.readyState !== 'complete') {
return _awaitIgnored(new Promise(function (res) {
return addEventListener('load', res);
}));
}
}, function () {
// Set this flag to true if any service worker was controlling the page
// at registration time.
_this2._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
// the page, and if that SW script (and version, if specified) matches this
// instance's script.
_this2._compatibleControllingSW = _this2._getControllingSWIfCompatible();
return _await(_this2._registerScript(), function (_this2$_registerScrip) {
_this2._registration = _this2$_registerScrip;
// If we have a compatible controller, store the controller as the "own"
// SW, resolve active/controlling deferreds and add necessary listeners.
if (_this2._compatibleControllingSW) {
_this2._sw = _this2._compatibleControllingSW;
_this2._activeDeferred.resolve(_this2._compatibleControllingSW);
_this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
_this2._reportWindowReady(_this2._compatibleControllingSW);
_this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
once: true
});
} // If there's a waiting service worker with a matching URL before the
// `updatefound` event fires, it likely means that this site is open
// in another tab, or the user refreshed the page (and thus the prevoius
// page wasn't fully unloaded before this page started loading).
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
var waitingSW = _this2._registration.waiting;
if (waitingSW && urlsMatch(waitingSW.scriptURL, _this2._scriptURL)) {
// Store the waiting SW as the "own" Sw, even if it means overwriting
// a compatible controller.
_this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
// listener after awaiting `register()` will get this event.
Promise.resolve().then(function () {
_this2.dispatchEvent(new WorkboxEvent('waiting', {
sw: waitingSW,
wasWaitingBeforeRegister: true
}));
{
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
}
});
} // If an "own" SW is already set, resolve the deferred.
if (_this2._sw) {
_this2._swDeferred.resolve(_this2._sw);
}
{
logger.log('Successfully registered service worker.', _this2._scriptURL);
if (navigator.serviceWorker.controller) {
if (_this2._compatibleControllingSW) {
logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
} else {
logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
}
}
var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
var scopeURL = new URL(_this2._registerOptions.scope || _this2._scriptURL, document.baseURI);
var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
return !location.pathname.startsWith(scopeURLBasePath);
};
if (currentPageIsOutOfScope()) {
logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
}
}
_this2._registration.addEventListener('updatefound', _this2._onUpdateFound);
navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
once: true
}); // Add message listeners.
if ('BroadcastChannel' in self) {
_this2._broadcastChannel = new BroadcastChannel('workbox');
_this2._broadcastChannel.addEventListener('message', _this2._onMessage);
}
navigator.serviceWorker.addEventListener('message', _this2._onMessage);
return _this2._registration;
});
});
});
/**
* Resolves to the service worker registered by this instance as soon as it
* is active. If a service worker was already controlling at registration
* time then it will resolve to that if the script URLs (and optionally
* script versions) match, otherwise it will wait until an update is found
* and activates.
*
* @return {Promise<ServiceWorker>}
*/
/**
* Resolves with a reference to a service worker that matches the script URL
* of this instance, as soon as it's available.
*
* If, at registration time, there's already an active or waiting service
* worker with a matching script URL, it will be used (with the waiting
* service worker taking precedence over the active service worker if both
* match, since the waiting service worker would have been registered more
* recently).
* If there's no matching active or waiting service worker at registration
* time then the promise will not resolve until an update is found and starts
* installing, at which point the installing service worker is used.
*
* @return {Promise<ServiceWorker>}
*/
_proto.getSW = _async(function () {
var _this3 = this;
// If `this._sw` is set, resolve with that as we want `getSW()` to
// return the correct (new) service worker if an update is found.
return _this3._sw || _this3._swDeferred.promise;
});
/**
* Sends the passed data object to the service worker registered by this
* instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
* with a response (if any).
*
* A response can be set in a message handler in the service worker by
* calling `event.ports[0].postMessage(...)`, which will resolve the promise
* returned by `messageSW()`. If no response is set, the promise will never
* resolve.
*
* @param {Object} data An object to send to the service worker
* @return {Promise<Object>}
*/
_proto.messageSW = _async(function (data) {
var _this4 = this;
return _await(_this4.getSW(), function (sw) {
return messageSW(sw, data);
});
});
/**
* Checks for a service worker already controlling the page and returns
* it if its script URL matchs.
*
* @private
* @return {ServiceWorker|undefined}
*/
_proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
var controller = navigator.serviceWorker.controller;
if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
return controller;
}
};
/**
* Registers a service worker for this instances script URL and register
* options and tracks the time registration was complete.
*
* @private
*/
_proto._registerScript = _async(function () {
var _this5 = this;
return _catch(function () {
return _await(navigator.serviceWorker.register(_this5._scriptURL, _this5._registerOptions), function (reg) {
// Keep track of when registration happened, so it can be used in the
// `this._onUpdateFound` heuristic. Also use the presence of this
// property as a way to see if `.register()` has been called.
_this5._registrationTime = performance.now();
return reg;
});
}, function (error) {
{
logger.error(error);
} // Re-throw the error.
throw error;
});
});
/**
* Sends a message to the passed service worker that the window is ready.
*
* @param {ServiceWorker} sw
* @private
*/
_proto._reportWindowReady = function _reportWindowReady(sw) {
messageSW(sw, {
type: 'WINDOW_READY',
meta: 'workbox-window'
});
};
/**
* @private
*/
_proto._onUpdateFound = function _onUpdateFound() {
var installingSW = this._registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
// different from the current controlling SW's script URL, we know any
// successful registration calls will trigger an `updatefound` event.
// But if the registered script URL is the same as the current controlling
// SW's script URL, we'll only get an `updatefound` event if the file
// changed since it was last registered. This can be a problem if the user
// opens up the same page in a different tab, and that page registers
// a SW that triggers an update. It's a problem because this page has no
// good way of knowing whether the `updatefound` event came from the SW
// script it registered or from a registration attempt made by a newer
// version of the page running in another tab.
// To minimize the possibility of a false positive, we use the logic here:
var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
// add the `updatefound` event listener until the `register()` call, if
// `_updateFoundCount` is > 0 then it means this method has already
// been called, thus this SW must be external
this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
// instance's script URL, we know it's definitely not from our
// registration.
!urlsMatch(installingSW.scriptURL, this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
// Any `updatefound` event that occurs long after our registration is
// assumed to be external.
performance.now() > this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
// triggered by this instance.
true : false;
if (updateLikelyTriggeredExternally) {
this._externalSW = installingSW;
this._registration.removeEventListener('updatefound', this._onUpdateFound);
} else {
// If the update was not triggered externally we know the installing
// SW is the one we registered, so we set it.
this._sw = installingSW;
this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
// callback for, but we do log messages for it in development.
{
if (navigator.serviceWorker.controller) {
logger.log('Updated service worker found. Installing now...');
} else {
logger.log('Service worker is installing...');
}
}
} // Increment the `updatefound` count, so future invocations of this
// method can be sure they were triggered externally.
++this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
// triggered externally, since we have callbacks for both.
installingSW.addEventListener('statechange', this._onStateChange);
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onStateChange = function _onStateChange(originalEvent) {
var _this6 = this;
var sw = originalEvent.target;
var state = sw.state;
var isExternal = sw === this._externalSW;
var eventPrefix = isExternal ? 'external' : '';
var eventProps = {
sw: sw,
originalEvent: originalEvent
};
if (!isExternal && this._isUpdate) {
eventProps.isUpdate = true;
}
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
if (state === 'installed') {
// This timeout is used to ignore cases where the service worker calls
// `skipWaiting()` in the install event, thus moving it directly in the
// activating state. (Since all service workers *must* go through the
// waiting phase, the only way to detect `skipWaiting()` called in the
// install event is to observe that the time spent in the waiting phase
// is very short.)
// NOTE: we don't need separate timeouts for the own and external SWs
// since they can't go through these phases at the same time.
this._waitingTimeout = setTimeout(function () {
// Ensure the SW is still waiting (it may now be redundant).
if (state === 'installed' && _this6._registration.waiting === sw) {
_this6.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
{
if (isExternal) {
logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
} else {
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
}
}
}
}, WAITING_TIMEOUT_DURATION);
} else if (state === 'activating') {
clearTimeout(this._waitingTimeout);
if (!isExternal) {
this._activeDeferred.resolve(sw);
}
}
{
switch (state) {
case 'installed':
if (isExternal) {
logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
} else {
logger.log('Registered service worker installed.');
}
break;
case 'activated':
if (isExternal) {
logger.warn('An external service worker has activated.');
} else {
logger.log('Registered service worker activated.');
if (sw !== navigator.serviceWorker.controller) {
logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
}
}
break;
case 'redundant':
if (sw === this._compatibleControllingSW) {
logger.log('Previously controlling service worker now redundant!');
} else if (!isExternal) {
logger.log('Registered service worker now redundant!');
}
break;
}
}
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onControllerChange = function _onControllerChange(originalEvent) {
var sw = this._sw;
if (sw === navigator.serviceWorker.controller) {
this.dispatchEvent(new WorkboxEvent('controlling', {
sw: sw,
originalEvent: originalEvent
}));
{
logger.log('Registered service worker now controlling this page.');
}
this._controllingDeferred.resolve(sw);
}
};
/**
* @private
* @param {Event} originalEvent
*/
_proto._onMessage = function _onMessage(originalEvent) {
var data = originalEvent.data;
this.dispatchEvent(new WorkboxEvent('message', {
data: data,
originalEvent: originalEvent
}));
};
_createClass(Workbox, [{
key: "active",
get: function get() {
return this._activeDeferred.promise;
}
/**
* Resolves to the service worker registered by this instance as soon as it
* is controlling the page. If a service worker was already controlling at
* registration time then it will resolve to that if the script URLs (and
* optionally script versions) match, otherwise it will wait until an update
* is found and starts controlling the page.
* Note: the first time a service worker is installed it will active but
* not start controlling the page unless `clients.claim()` is called in the
* service worker.
*
* @return {Promise<ServiceWorker>}
*/
}, {
key: "controlling",
get: function get() {
return this._controllingDeferred.promise;
}
}]);
return Workbox;
}(EventTargetShim); // The jsdoc comments below outline the events this instance may dispatch:
/*
Copyright 2019 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
exports.Workbox = Workbox;
exports.messageSW = messageSW;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=workbox-window.dev.umd.js.map
{"version":3,"file":"workbox-window.dev.umd.js","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../../workbox-core/_private/logger.mjs","../utils/EventTargetShim.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\nconst logger = process.env.NODE_ENV === 'production' ? null : (() => {\n let inGroup = false;\n\n const methodToColorMap = {\n debug: `#7f8c8d`, // Gray\n log: `#2ecc71`, // Green\n warn: `#f39c12`, // Yellow\n error: `#c0392b`, // Red\n groupCollapsed: `#3498db`, // Blue\n groupEnd: null, // No colored prefix on groupEnd\n };\n\n const print = function(method, args) {\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n\n console[method](...logPrefix, ...args);\n\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n\n const api = {};\n for (const method of Object.keys(methodToColorMap)) {\n api[method] = (...args) => {\n print(method, args);\n };\n }\n\n return api;\n})();\n\nexport {logger};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {messageSW} from './messageSW.mjs';\nimport {Workbox} from './Workbox.mjs';\nimport './_version.mjs';\n\n\n/**\n * @module workbox-window\n */\nexport {\n Workbox,\n messageSW,\n};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","promise","reject","logger","process","inGroup","methodToColorMap","debug","log","warn","error","groupCollapsed","groupEnd","print","method","args","test","navigator","userAgent","console","styles","logPrefix","join","api","Object","keys","EventTargetShim","_eventListenerRegistry","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","event","target","forEach","Set","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","props","assign","body","recover","result","then","f","i","arguments","length","apply","value","direct","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","register","immediate","_registrationTime","document","readyState","res","_isUpdate","Boolean","serviceWorker","controller","_compatibleControllingSW","_getControllingSWIfCompatible","_registerScript","_registration","_sw","_reportWindowReady","once","waitingSW","waiting","wasWaitingBeforeRegister","currentPageIsOutOfScope","scopeURL","scope","baseURI","scopeURLBasePath","pathname","startsWith","_broadcastChannel","BroadcastChannel","getSW","reg","performance","now","meta","installingSW","installing","updateLikelyTriggeredExternally","_externalSW","originalEvent","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","clearTimeout"],"mappings":";;;;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,sBAAD,CAAJ,IAA8BC,CAAC,EAA/B;EAAkC,CAAtC,CAAsC,OAAMC,CAAN,EAAQ;;ECA9C;;;;;;;AAQA,EAGA;;;;;;;;;;;;;;;;AAeA,MAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,EAAD,EAAKC,IAAL,EAAc;EAC9B,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;EAC9B,QAAIC,cAAc,GAAG,IAAIC,cAAJ,EAArB;;EACAD,IAAAA,cAAc,CAACE,KAAf,CAAqBC,SAArB,GAAiC,UAACC,GAAD;EAAA,aAASL,OAAO,CAACK,GAAG,CAACP,IAAL,CAAhB;EAAA,KAAjC;;EACAD,IAAAA,EAAE,CAACS,WAAH,CAAeR,IAAf,EAAqB,CAACG,cAAc,CAACM,KAAhB,CAArB;EACD,GAJM,CAAP;EAKD,CAND;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EC1BA,IAAG;EAACd,EAAAA,IAAI,CAAC,oBAAD,CAAJ,IAA4BC,CAAC,EAA7B;EAAgC,CAApC,CAAoC,OAAMC,CAAN,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FJ;EAGD;EACF;;EACD;;EACF,aAAK,WAAL;EACE,cAAIpB,EAAE,KAAK,KAAKiG,wBAAhB,EAA0C;EACxCnF,YAAAA,MAAM,CAACK,GAAP,CAAW,sDAAX;EACD,WAFD,MAEO,IAAI,CAAC4G,UAAL,EAAiB;EACtBjH,YAAAA,MAAM,CAACK,GAAP,CAAW,0CAAX;EACD;;EACD;EA3BJ;EA6BD;EACF;EAED;;;;;;WAIAmE,mDAAoBuC,eAAe;EACjC,QAAM7H,EAAE,GAAG,KAAKqG,GAAhB;;EACA,QAAIrG,EAAE,KAAK4B,SAAS,CAACmE,aAAV,CAAwBC,UAAnC,EAA+C;EAC7C,WAAKlD,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,aAAjB,EAAgC;EAACzD,QAAAA,EAAE,EAAFA,EAAD;EAAK6H,QAAAA,aAAa,EAAbA;EAAL,OAAhC,CAAnB;;EACA,MAA2C;EACzC/G,QAAAA,MAAM,CAACK,GAAP,CAAW,sDAAX;EACD;;EACD,WAAK8D,oBAAL,CAA0B9E,OAA1B,CAAkCH,EAAlC;EACD;EACF;EAED;;;;;;WAIAkF,iCAAW2C,eAAe;EAAA,QACjB5H,IADiB,GACT4H,aADS,CACjB5H,IADiB;EAExB,SAAK6C,aAAL,CAAmB,IAAIW,YAAJ,CAAiB,SAAjB,EAA4B;EAACxD,MAAAA,IAAI,EAAJA,IAAD;EAAO4H,MAAAA,aAAa,EAAbA;EAAP,KAA5B,CAAnB;EACD;;;;0BA9RY;EACX,aAAO,KAAK7C,eAAL,CAAqBpE,OAA5B;EACD;EAED;;;;;;;;;;;;;;;0BAYkB;EAChB,aAAO,KAAKqE,oBAAL,CAA0BrE,OAAjC;EACD;;;;IA9KmByB;;EC1CtB;;;;;;;;;;;;;;;;;;;"}
\ No newline at end of file
try{self["workbox:window:4.3.1"]&&_()}catch(n){}var n=function(n,t){return new Promise(function(i){var e=new MessageChannel;e.port1.onmessage=function(n){return i(n.data)},n.postMessage(t,[e.port2])})};function t(n,t){for(var i=0;i<t.length;i++){var e=t[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}function i(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}try{self["workbox:core:4.3.1"]&&_()}catch(n){}var e=function(){var n=this;this.promise=new Promise(function(t,i){n.resolve=t,n.reject=i})},r=function(n,t){return new URL(n,location).href===new URL(t,location).href},o=function(n,t){Object.assign(this,t,{type:n})};function u(n){return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function a(n,t,i){return i?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function s(){}var c=function(c){var f,h;function v(n,t){var r;return void 0===t&&(t={}),(r=c.call(this)||this).t=n,r.i=t,r.o=0,r.u=new e,r.s=new e,r.h=new e,r.v=r.v.bind(i(i(r))),r.l=r.l.bind(i(i(r))),r.g=r.g.bind(i(i(r))),r.m=r.m.bind(i(i(r))),r}h=c,(f=v).prototype=Object.create(h.prototype),f.prototype.constructor=f,f.__proto__=h;var l,w,g,d=v.prototype;return d.register=u(function(n){var t,i,e=this,u=(void 0===n?{}:n).immediate,c=void 0!==u&&u;return t=function(){return e.p=Boolean(navigator.serviceWorker.controller),e.P=e.R(),a(e.k(),function(n){e.B=n,e.P&&(e.O=e.P,e.s.resolve(e.P),e.h.resolve(e.P),e.j(e.P),e.P.addEventListener("statechange",e.l,{once:!0}));var t=e.B.waiting;return t&&r(t.scriptURL,e.t)&&(e.O=t,Promise.resolve().then(function(){e.dispatchEvent(new o("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})),e.O&&e.u.resolve(e.O),e.B.addEventListener("updatefound",e.g),navigator.serviceWorker.addEventListener("controllerchange",e.m,{once:!0}),"BroadcastChannel"in self&&(e.C=new BroadcastChannel("workbox"),e.C.addEventListener("message",e.v)),navigator.serviceWorker.addEventListener("message",e.v),e.B})},(i=function(){if(!c&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(s):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&i.then?i.then(t):t(i)}),d.getSW=u(function(){return this.O||this.u.promise}),d.messageSW=u(function(t){return a(this.getSW(),function(i){return n(i,t)})}),d.R=function(){var n=navigator.serviceWorker.controller;if(n&&r(n.scriptURL,this.t))return n},d.k=u(function(){var n=this;return function(n,t){try{var i=n()}catch(n){return t(n)}return i&&i.then?i.then(void 0,t):i}(function(){return a(navigator.serviceWorker.register(n.t,n.i),function(t){return n.L=performance.now(),t})},function(n){throw n})}),d.j=function(t){n(t,{type:"WINDOW_READY",meta:"workbox-window"})},d.g=function(){var n=this.B.installing;this.o>0||!r(n.scriptURL,this.t)||performance.now()>this.L+6e4?(this.W=n,this.B.removeEventListener("updatefound",this.g)):(this.O=n,this.u.resolve(n)),++this.o,n.addEventListener("statechange",this.l)},d.l=function(n){var t=this,i=n.target,e=i.state,r=i===this.W,u=r?"external":"",a={sw:i,originalEvent:n};!r&&this.p&&(a.isUpdate=!0),this.dispatchEvent(new o(u+e,a)),"installed"===e?this._=setTimeout(function(){"installed"===e&&t.B.waiting===i&&t.dispatchEvent(new o(u+"waiting",a))},200):"activating"===e&&(clearTimeout(this._),r||this.s.resolve(i))},d.m=function(n){var t=this.O;t===navigator.serviceWorker.controller&&(this.dispatchEvent(new o("controlling",{sw:t,originalEvent:n})),this.h.resolve(t))},d.v=function(n){var t=n.data;this.dispatchEvent(new o("message",{data:t,originalEvent:n}))},l=v,(w=[{key:"active",get:function(){return this.s.promise}},{key:"controlling",get:function(){return this.h.promise}}])&&t(l.prototype,w),g&&t(l,g),v}(function(){function n(){this.D={}}var t=n.prototype;return t.addEventListener=function(n,t){this.T(n).add(t)},t.removeEventListener=function(n,t){this.T(n).delete(t)},t.dispatchEvent=function(n){n.target=this,this.T(n.type).forEach(function(t){return t(n)})},t.T=function(n){return this.D[n]=this.D[n]||new Set},n}());export{c as Workbox,n as messageSW};
//# sourceMappingURL=workbox-window.prod.es5.mjs.map
{"version":3,"file":"workbox-window.prod.es5.mjs","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs","../utils/EventTargetShim.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","type","props","Object","assign","this","f","args","i","arguments","length","apply","value","then","direct","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","register","result","immediate","_isUpdate","Boolean","navigator","serviceWorker","controller","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","_registration","_sw","_reportWindowReady","addEventListener","once","waitingSW","waiting","dispatchEvent","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","document","readyState","res","body","getSW","recover","_this5","reg","_registrationTime","performance","now","error","meta","installingSW","installing","_externalSW","removeEventListener","originalEvent","target","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","_this6","clearTimeout","_eventListenerRegistry","listener","_getEventListenersByType","add","delete","event","forEach","Set"],"mappings":"AAAA,IAAIA,KAAK,yBAAyBC,IAAI,MAAMC,IC0B5C,IAAMC,EAAY,SAACC,EAAIC,UACd,IAAIC,QAAQ,SAACC,OACdC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,UAAQL,EAAQK,EAAIP,OACtDD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,4SC9BzC,IAAId,KAAK,uBAAuBC,IAAI,MAAMC,QCmB7Ba,EAIX,2BACOC,QAAU,IAAIV,QAAQ,SAACC,EAASU,GACnCC,EAAKX,QAAUA,EACfW,EAAKD,OAASA,KCNdE,EAAY,SAACC,EAAMC,UAChB,IAAIC,IAAIF,EAAMG,UAAUC,OAAS,IAAIF,IAAID,EAAME,UAAUC,MCL5DC,EAKJ,SAAYC,EAAMC,GAChBC,OAAOC,OAAOC,KAAMH,EAAO,CAACD,KAAAA,KCgDzB,WAAgBK,UACf,eACD,IAAIC,EAAO,GAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAChDD,EAAKC,GAAKC,UAAUD,cAGb3B,QAAQC,QAAQwB,EAAEK,MAAMN,KAAME,IACpC,MAAM9B,UACAI,QAAQW,OAAOf,KAMlB,WAAgBmC,EAAOC,EAAMC,UAC/BA,EACID,EAAOA,EAAKD,GAASA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GAAAA,EAAI0F,cAAAA,IACnBG,GAAcnE,KAAK2B,IACtB0C,EAAWC,UAAW,QAGnB3B,cAAc,IAAIhD,EACnByE,EAAcF,EAAOG,IAEX,cAAVH,OASGK,EAAkBC,WAAW,WAElB,cAAVN,GAAyBO,EAAKrC,EAAcM,UAAYpE,GAC1DmG,EAAK9B,cAAc,IAAIhD,EACnByE,EAAc,UAAWC,KArYN,KAkZR,eAAVH,IACTQ,aAAa1E,KAAKuE,GACbJ,QACElD,EAAgBxC,QAAQH,OAyCnCiD,WAAoByC,OACZ1F,EAAK0B,KAAKqC,EACZ/D,IAAOuD,UAAUC,cAAcC,kBAC5BY,cAAc,IAAIhD,EAAa,cAAe,CAACrB,GAAAA,EAAI0F,cAAAA,UAInD9C,EAAqBzC,QAAQH,OAQtC6C,WAAW6C,OACFzF,EAAQyF,EAARzF,UACFoE,cAAc,IAAIhD,EAAa,UAAW,CAACpB,KAAAA,EAAMyF,cAAAA,kDA5R/ChE,KAAKiB,EAAgB/B,mDAgBrBc,KAAKkB,EAAqBhC,wEC9L5ByF,EAAyB,8BAOhCpC,0BAAiB3C,EAAMgF,QAChBC,EAAyBjF,GAAMkF,IAAIF,MAQ1Cb,6BAAoBnE,EAAMgF,QACnBC,EAAyBjF,GAAMmF,OAAOH,MAO7CjC,uBAAcqC,GACZA,EAAMf,OAASjE,UACV6E,EAAyBG,EAAMpF,MAAMqF,QACtC,SAACL,UAAaA,EAASI,QAW7BH,WAAyBjF,UAChBI,KAAK2E,EAAuB/E,GAC9BI,KAAK2E,EAAuB/E,IAAS,IAAIsF"}
\ No newline at end of file
try{self["workbox:window:4.3.1"]&&_()}catch(t){}const t=(t,s)=>new Promise(i=>{let e=new MessageChannel;e.port1.onmessage=(t=>i(t.data)),t.postMessage(s,[e.port2])});try{self["workbox:core:4.3.1"]&&_()}catch(t){}class s{constructor(){this.promise=new Promise((t,s)=>{this.resolve=t,this.reject=s})}}class i{constructor(){this.t={}}addEventListener(t,s){this.s(t).add(s)}removeEventListener(t,s){this.s(t).delete(s)}dispatchEvent(t){t.target=this,this.s(t.type).forEach(s=>s(t))}s(t){return this.t[t]=this.t[t]||new Set}}const e=(t,s)=>new URL(t,location).href===new URL(s,location).href;class n{constructor(t,s){Object.assign(this,s,{type:t})}}const h=200,a=6e4;class o extends i{constructor(t,i={}){super(),this.i=t,this.h=i,this.o=0,this.l=new s,this.g=new s,this.u=new s,this.m=this.m.bind(this),this.v=this.v.bind(this),this.p=this.p.bind(this),this._=this._.bind(this)}async register({immediate:t=!1}={}){t||"complete"===document.readyState||await new Promise(t=>addEventListener("load",t)),this.C=Boolean(navigator.serviceWorker.controller),this.W=this.L(),this.S=await this.B(),this.W&&(this.R=this.W,this.g.resolve(this.W),this.u.resolve(this.W),this.P(this.W),this.W.addEventListener("statechange",this.v,{once:!0}));const s=this.S.waiting;return s&&e(s.scriptURL,this.i)&&(this.R=s,Promise.resolve().then(()=>{this.dispatchEvent(new n("waiting",{sw:s,wasWaitingBeforeRegister:!0}))})),this.R&&this.l.resolve(this.R),this.S.addEventListener("updatefound",this.p),navigator.serviceWorker.addEventListener("controllerchange",this._,{once:!0}),"BroadcastChannel"in self&&(this.T=new BroadcastChannel("workbox"),this.T.addEventListener("message",this.m)),navigator.serviceWorker.addEventListener("message",this.m),this.S}get active(){return this.g.promise}get controlling(){return this.u.promise}async getSW(){return this.R||this.l.promise}async messageSW(s){const i=await this.getSW();return t(i,s)}L(){const t=navigator.serviceWorker.controller;if(t&&e(t.scriptURL,this.i))return t}async B(){try{const t=await navigator.serviceWorker.register(this.i,this.h);return this.U=performance.now(),t}catch(t){throw t}}P(s){t(s,{type:"WINDOW_READY",meta:"workbox-window"})}p(){const t=this.S.installing;this.o>0||!e(t.scriptURL,this.i)||performance.now()>this.U+a?(this.k=t,this.S.removeEventListener("updatefound",this.p)):(this.R=t,this.l.resolve(t)),++this.o,t.addEventListener("statechange",this.v)}v(t){const s=t.target,{state:i}=s,e=s===this.k,a=e?"external":"",o={sw:s,originalEvent:t};!e&&this.C&&(o.isUpdate=!0),this.dispatchEvent(new n(a+i,o)),"installed"===i?this.D=setTimeout(()=>{"installed"===i&&this.S.waiting===s&&this.dispatchEvent(new n(a+"waiting",o))},h):"activating"===i&&(clearTimeout(this.D),e||this.g.resolve(s))}_(t){const s=this.R;s===navigator.serviceWorker.controller&&(this.dispatchEvent(new n("controlling",{sw:s,originalEvent:t})),this.u.resolve(s))}m(t){const{data:s}=t;this.dispatchEvent(new n("message",{data:s,originalEvent:t}))}}export{o as Workbox,t as messageSW};
//# sourceMappingURL=workbox-window.prod.mjs.map
{"version":3,"file":"workbox-window.prod.mjs","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../utils/EventTargetShim.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","constructor","promise","reject","EventTargetShim","_eventListenerRegistry","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","event","target","this","forEach","Set","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","props","Object","assign","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","immediate","document","readyState","res","_isUpdate","Boolean","navigator","serviceWorker","controller","_compatibleControllingSW","_getControllingSWIfCompatible","_registration","_registerScript","_sw","_reportWindowReady","once","waitingSW","waiting","then","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","getSW","reg","register","_registrationTime","performance","now","error","meta","installingSW","installing","_externalSW","originalEvent","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","clearTimeout"],"mappings":"AAAA,IAAIA,KAAK,yBAAyBC,IAAI,MAAMC,UC0BtCC,EAAY,CAACC,EAAIC,IACd,IAAIC,QAASC,QACdC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAaC,CAAAA,GAAQL,EAAQK,EAAIP,OACtDD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,UC9BzC,IAAId,KAAK,uBAAuBC,IAAI,MAAMC,ICmB1C,MAAaa,EAIXC,mBACOC,QAAU,IAAIX,QAAQ,CAACC,EAASW,UAC9BX,QAAUA,OACVW,OAASA,KCTpB,MAAMC,EAMJH,mBAEOI,EAAyB,GAOhCC,iBAAiBC,EAAMC,QAChBC,EAAyBF,GAAMG,IAAIF,GAQ1CG,oBAAoBJ,EAAMC,QACnBC,EAAyBF,GAA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EAAa3F,IAAO2B,KAAK6D,EACzBI,EAAcD,EAAa,WAAa,GAExCE,EAAa,CAAC7F,GAAAA,EAAIyF,cAAAA,IACnBE,GAAchE,KAAKiC,IACtBiC,EAAWC,UAAW,QAGnBtE,cAAc,IAAIY,EACnBwD,EAAcF,EAAOG,IAEX,cAAVH,OASGK,EAAkBC,WAAW,KAElB,cAAVN,GAAyB/D,KAAKwC,EAAcM,UAAYzE,QACrDwB,cAAc,IAAIY,EACnBwD,EAAc,UAAWC,KAY9BrD,GACgB,eAAVkD,IACTO,aAAatE,KAAKoE,GACbJ,QACE1C,EAAgB9C,QAAQH,IAyCnCuD,EAAoBkC,SACZzF,EAAK2B,KAAK0C,EACZrE,IAAO8D,UAAUC,cAAcC,kBAC5BxC,cAAc,IAAIY,EAAa,cAAe,CAACpC,GAAAA,EAAIyF,cAAAA,UAInDvC,EAAqB/C,QAAQH,IAQtCmD,EAAWsC,SACHxF,KAACA,GAAQwF,OACVjE,cAAc,IAAIY,EAAa,UAAW,CAACnC,KAAAA,EAAMwF,cAAAA"}
\ No newline at end of file
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).workbox={})}(this,function(n){"use strict";try{self["workbox:window:4.3.1"]&&_()}catch(n){}var t=function(n,t){return new Promise(function(i){var e=new MessageChannel;e.port1.onmessage=function(n){return i(n.data)},n.postMessage(t,[e.port2])})};function i(n,t){for(var i=0;i<t.length;i++){var e=t[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}function e(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}try{self["workbox:core:4.3.1"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,i){n.resolve=t,n.reject=i})},o=function(n,t){return new URL(n,location).href===new URL(t,location).href},u=function(n,t){Object.assign(this,t,{type:n})};function s(n){return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function a(n,t,i){return i?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function c(){}var f=function(n){var f,h;function v(t,i){var o;return void 0===i&&(i={}),(o=n.call(this)||this).t=t,o.i=i,o.o=0,o.u=new r,o.s=new r,o.h=new r,o.v=o.v.bind(e(e(o))),o.l=o.l.bind(e(e(o))),o.g=o.g.bind(e(e(o))),o.m=o.m.bind(e(e(o))),o}h=n,(f=v).prototype=Object.create(h.prototype),f.prototype.constructor=f,f.__proto__=h;var l,w,d,g=v.prototype;return g.register=s(function(n){var t,i,e=this,r=(void 0===n?{}:n).immediate,s=void 0!==r&&r;return t=function(){return e.p=Boolean(navigator.serviceWorker.controller),e.P=e.j(),a(e.O(),function(n){e.R=n,e.P&&(e._=e.P,e.s.resolve(e.P),e.h.resolve(e.P),e.k(e.P),e.P.addEventListener("statechange",e.l,{once:!0}));var t=e.R.waiting;return t&&o(t.scriptURL,e.t)&&(e._=t,Promise.resolve().then(function(){e.dispatchEvent(new u("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})),e._&&e.u.resolve(e._),e.R.addEventListener("updatefound",e.g),navigator.serviceWorker.addEventListener("controllerchange",e.m,{once:!0}),"BroadcastChannel"in self&&(e.B=new BroadcastChannel("workbox"),e.B.addEventListener("message",e.v)),navigator.serviceWorker.addEventListener("message",e.v),e.R})},(i=function(){if(!s&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(c):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&i.then?i.then(t):t(i)}),g.getSW=s(function(){return this._||this.u.promise}),g.messageSW=s(function(n){return a(this.getSW(),function(i){return t(i,n)})}),g.j=function(){var n=navigator.serviceWorker.controller;if(n&&o(n.scriptURL,this.t))return n},g.O=s(function(){var n=this;return function(n,t){try{var i=n()}catch(n){return t(n)}return i&&i.then?i.then(void 0,t):i}(function(){return a(navigator.serviceWorker.register(n.t,n.i),function(t){return n.C=performance.now(),t})},function(n){throw n})}),g.k=function(n){t(n,{type:"WINDOW_READY",meta:"workbox-window"})},g.g=function(){var n=this.R.installing;this.o>0||!o(n.scriptURL,this.t)||performance.now()>this.C+6e4?(this.L=n,this.R.removeEventListener("updatefound",this.g)):(this._=n,this.u.resolve(n)),++this.o,n.addEventListener("statechange",this.l)},g.l=function(n){var t=this,i=n.target,e=i.state,r=i===this.L,o=r?"external":"",s={sw:i,originalEvent:n};!r&&this.p&&(s.isUpdate=!0),this.dispatchEvent(new u(o+e,s)),"installed"===e?this.W=setTimeout(function(){"installed"===e&&t.R.waiting===i&&t.dispatchEvent(new u(o+"waiting",s))},200):"activating"===e&&(clearTimeout(this.W),r||this.s.resolve(i))},g.m=function(n){var t=this._;t===navigator.serviceWorker.controller&&(this.dispatchEvent(new u("controlling",{sw:t,originalEvent:n})),this.h.resolve(t))},g.v=function(n){var t=n.data;this.dispatchEvent(new u("message",{data:t,originalEvent:n}))},l=v,(w=[{key:"active",get:function(){return this.s.promise}},{key:"controlling",get:function(){return this.h.promise}}])&&i(l.prototype,w),d&&i(l,d),v}(function(){function n(){this.D={}}var t=n.prototype;return t.addEventListener=function(n,t){this.M(n).add(t)},t.removeEventListener=function(n,t){this.M(n).delete(t)},t.dispatchEvent=function(n){n.target=this,this.M(n.type).forEach(function(t){return t(n)})},t.M=function(n){return this.D[n]=this.D[n]||new Set},n}());n.Workbox=f,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=workbox-window.prod.umd.js.map
{"version":3,"file":"workbox-window.prod.umd.js","sources":["../_version.mjs","../messageSW.mjs","../../workbox-core/_version.mjs","../../workbox-core/_private/Deferred.mjs","../utils/urlsMatch.mjs","../utils/WorkboxEvent.mjs","../Workbox.mjs","../utils/EventTargetShim.mjs"],"sourcesContent":["try{self['workbox:window:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport './_version.mjs';\n\n\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nconst messageSW = (sw, data) => {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (evt) => resolve(evt.data);\n sw.postMessage(data, [messageChannel.port2]);\n });\n};\n\nexport {messageSW};\n","try{self['workbox:core:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nexport class Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nconst urlsMatch = (url1, url2) => {\n return new URL(url1, location).href === new URL(url2, location).href;\n};\n\nexport {urlsMatch};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nclass WorkboxEvent {\n /**\n * @param {string} type\n * @param {Object} props\n */\n constructor(type, props) {\n Object.assign(this, props, {type});\n }\n}\n\nexport {WorkboxEvent};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Deferred} from 'workbox-core/_private/Deferred.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {messageSW} from './messageSW.mjs';\nimport {EventTargetShim} from './utils/EventTargetShim.mjs';\nimport {urlsMatch} from './utils/urlsMatch.mjs';\nimport {WorkboxEvent} from './utils/WorkboxEvent.mjs';\nimport './_version.mjs';\n\n\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n *\n * @memberof module:workbox-window\n */\nclass Workbox extends EventTargetShim {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n this._updateFoundCount = 0;\n\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n\n // Bind event handler callbacks.\n this._onMessage = this._onMessage.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._onUpdateFound = this._onUpdateFound.bind(this);\n this._onControllerChange = this._onControllerChange.bind(this);\n }\n\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({immediate = false} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => addEventListener('load', res));\n }\n\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n\n this._registration = await this._registerScript();\n\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n\n this._reportWindowReady(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener(\n 'statechange', this._onStateChange, {once: true});\n }\n\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the prevoius\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n });\n }\n\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n } else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(\n this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener(\n 'controllerchange', this._onControllerChange, {once: true});\n\n // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n\n return this._registration;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw || this._swDeferred.promise;\n }\n\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matchs.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n }\n\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(\n this._scriptURL, this._registerOptions);\n\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n\n return reg;\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n\n\n /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n\n /**\n * @private\n */\n _onUpdateFound() {\n const installingSW = this._registration.installing;\n\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally =\n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n this._registration.removeEventListener(\n 'updatefound', this._onUpdateFound);\n } else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._swDeferred.resolve(installingSW);\n\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n } else {\n logger.log('Service worker is installing...');\n }\n }\n }\n\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onStateChange(originalEvent) {\n const sw = originalEvent.target;\n const {state} = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n\n const eventProps = {sw, originalEvent};\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + state, eventProps));\n\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && this._registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(\n eventPrefix + 'waiting', eventProps));\n\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n } else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n } else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n } else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n } else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n } else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onControllerChange(originalEvent) {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {sw, originalEvent}));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n }\n\n /**\n * @private\n * @param {Event} originalEvent\n */\n _onMessage(originalEvent) {\n const {data} = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', {data, originalEvent}));\n }\n}\n\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The native `controllerchange` event\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-external-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n\nexport {Workbox};\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nclass EventTargetShim {\n /**\n * Creates an event listener registry\n *\n * @private\n */\n constructor() {\n // A registry of event types to listeners.\n this._eventListenerRegistry = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).add(listener);\n }\n\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n\n /**\n * @param {Event} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n this._getEventListenersByType(event.type).forEach(\n (listener) => listener(event));\n }\n\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n\nexport {EventTargetShim};\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","evt","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","URL","location","href","WorkboxEvent","type","props","Object","assign","this","f","args","i","arguments","length","apply","value","then","direct","Workbox","scriptURL","registerOptions","_scriptURL","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_onMessage","bind","_onStateChange","_onUpdateFound","_onControllerChange","register","result","immediate","_isUpdate","Boolean","navigator","serviceWorker","controller","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","_registration","_sw","_reportWindowReady","addEventListener","once","waitingSW","waiting","dispatchEvent","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","document","readyState","res","body","getSW","recover","_this5","reg","_registrationTime","performance","now","error","meta","installingSW","installing","_externalSW","removeEventListener","originalEvent","target","state","isExternal","eventPrefix","eventProps","isUpdate","_waitingTimeout","setTimeout","_this6","clearTimeout","_eventListenerRegistry","listener","_getEventListenersByType","add","delete","event","forEach","Set"],"mappings":"oMAAA,IAAIA,KAAK,yBAAyBC,IAAI,MAAMC,QC0BtCC,EAAY,SAACC,EAAIC,UACd,IAAIC,QAAQ,SAACC,OACdC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,UAAQL,EAAQK,EAAIP,OACtDD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,4SC9BzC,IAAId,KAAK,uBAAuBC,IAAI,MAAMC,QCmB7Ba,EAIX,2BACOC,QAAU,IAAIV,QAAQ,SAACC,EAASU,GACnCC,EAAKX,QAAUA,EACfW,EAAKD,OAASA,KCNdE,EAAY,SAACC,EAAMC,UAChB,IAAIC,IAAIF,EAAMG,UAAUC,OAAS,IAAIF,IAAID,EAAME,UAAUC,MCL5DC,EAKJ,SAAYC,EAAMC,GAChBC,OAAOC,OAAOC,KAAMH,EAAO,CAACD,KAAAA,KCgDzB,WAAgBK,UACf,eACD,IAAIC,EAAO,GAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAChDD,EAAKC,GAAKC,UAAUD,cAGb3B,QAAQC,QAAQwB,EAAEK,MAAMN,KAAME,IACpC,MAAM9B,UACAI,QAAQW,OAAOf,KAMlB,WAAgBmC,EAAOC,EAAMC,UAC/BA,EACID,EAAOA,EAAKD,GAASA,GAExBA,GAAUA,EAAMC,OACpBD,EAAQ/B,QAAQC,QAAQ8B,IAElBC,EAAOD,EAAMC,KAAKA,GAAQD,GAugB3B,cA9kBP,IAsBMG,iCAYQC,EAAWC,yBAAAA,IAAAA,EAAkB,2BAGlCC,EAAaF,IACbG,EAAmBF,IACnBG,EAAoB,IAGpBC,EAAc,IAAI/B,IAClBgC,EAAkB,IAAIhC,IACtBiC,EAAuB,IAAIjC,IAG3BkC,EAAa/B,EAAK+B,EAAWC,gBAC7BC,EAAiBjC,EA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iD,WAAoByC,OACZ1F,EAAK0B,KAAKqC,EACZ/D,IAAOuD,UAAUC,cAAcC,kBAC5BY,cAAc,IAAIhD,EAAa,cAAe,CAACrB,GAAAA,EAAI0F,cAAAA,UAInD9C,EAAqBzC,QAAQH,OAQtC6C,WAAW6C,OACFzF,EAAQyF,EAARzF,UACFoE,cAAc,IAAIhD,EAAa,UAAW,CAACpB,KAAAA,EAAMyF,cAAAA,kDA5R/ChE,KAAKiB,EAAgB/B,mDAgBrBc,KAAKkB,EAAqBhC,wEC9L5ByF,EAAyB,8BAOhCpC,0BAAiB3C,EAAMgF,QAChBC,EAAyBjF,GAAMkF,IAAIF,MAQ1Cb,6BAAoBnE,EAAMgF,QACnBC,EAAyBjF,GAAMmF,OAAOH,MAO7CjC,uBAAcqC,GACZA,EAAMf,OAASjE,UACV6E,EAAyBG,EAAMpF,MAAMqF,QACtC,SAACL,UAAaA,EAASI,QAW7BH,WAAyBjF,UAChBI,KAAK2E,EAAuB/E,GAC9BI,KAAK2E,EAAuB/E,IAAS,IAAIsF"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment