all repos — caroster @ v0.4.0

[Octree] Group carpool to your event https://caroster.io

frontend/public/sw.js (view raw)

  1/**
  2 * Copyright 2018 Google Inc. All Rights Reserved.
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 *     http://www.apache.org/licenses/LICENSE-2.0
  7 * Unless required by applicable law or agreed to in writing, software
  8 * distributed under the License is distributed on an "AS IS" BASIS,
  9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 10 * See the License for the specific language governing permissions and
 11 * limitations under the License.
 12 */
 13
 14// If the loader is already loaded, just stop.
 15if (!self.define) {
 16  const singleRequire = name => {
 17    if (name !== 'require') {
 18      name = name + '.js';
 19    }
 20    let promise = Promise.resolve();
 21    if (!registry[name]) {
 22      
 23        promise = new Promise(async resolve => {
 24          if ("document" in self) {
 25            const script = document.createElement("script");
 26            script.src = name;
 27            document.head.appendChild(script);
 28            script.onload = resolve;
 29          } else {
 30            importScripts(name);
 31            resolve();
 32          }
 33        });
 34      
 35    }
 36    return promise.then(() => {
 37      if (!registry[name]) {
 38        throw new Error(`Module ${name} didn’t register its module`);
 39      }
 40      return registry[name];
 41    });
 42  };
 43
 44  const require = (names, resolve) => {
 45    Promise.all(names.map(singleRequire))
 46      .then(modules => resolve(modules.length === 1 ? modules[0] : modules));
 47  };
 48  
 49  const registry = {
 50    require: Promise.resolve(require)
 51  };
 52
 53  self.define = (moduleName, depsNames, factory) => {
 54    if (registry[moduleName]) {
 55      // Module is already loading or loaded.
 56      return;
 57    }
 58    registry[moduleName] = Promise.resolve().then(() => {
 59      let exports = {};
 60      const module = {
 61        uri: location.origin + moduleName.slice(1)
 62      };
 63      return Promise.all(
 64        depsNames.map(depName => {
 65          switch(depName) {
 66            case "exports":
 67              return exports;
 68            case "module":
 69              return module;
 70            default:
 71              return singleRequire(depName);
 72          }
 73        })
 74      ).then(deps => {
 75        const facValue = factory(...deps);
 76        if(!exports.default) {
 77          exports.default = facValue;
 78        }
 79        return exports;
 80      });
 81    });
 82  };
 83}
 84define("./sw.js",['./workbox-6b19f60b'], function (workbox) { 'use strict';
 85
 86  /**
 87  * Welcome to your Workbox-powered service worker!
 88  *
 89  * You'll need to register this file in your web app.
 90  * See https://goo.gl/nhQhGp
 91  *
 92  * The rest of the code is auto-generated. Please don't update this file
 93  * directly; instead, make changes to your Workbox build configuration
 94  * and re-run your build process.
 95  * See https://goo.gl/2aRDsh
 96  */
 97
 98  importScripts();
 99  self.skipWaiting();
100  workbox.clientsClaim();
101  workbox.registerRoute("/", new workbox.NetworkFirst({
102    "cacheName": "start-url",
103    plugins: [{
104      cacheWillUpdate: async ({
105        request,
106        response,
107        event,
108        state
109      }) => {
110        if (response && response.type === 'opaqueredirect') {
111          return new Response(response.body, {
112            status: 200,
113            statusText: 'OK',
114            headers: response.headers
115          });
116        }
117
118        return response;
119      }
120    }]
121  }), 'GET');
122  workbox.registerRoute(/.*/i, new workbox.NetworkOnly({
123    "cacheName": "dev",
124    plugins: []
125  }), 'GET');
126
127});
128//# sourceMappingURL=sw.js.map