sw.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // If the loader is already loaded, just stop.
  14. if (!self.define) {
  15. let registry = {};
  16. // Used for `eval` and `importScripts` where we can't get script URL by other means.
  17. // In both cases, it's safe to use a global var because those functions are synchronous.
  18. let nextDefineUri;
  19. const singleRequire = (uri, parentUri) => {
  20. uri = new URL(uri + ".js", parentUri).href;
  21. return registry[uri] || (
  22. new Promise(resolve => {
  23. if ("document" in self) {
  24. const script = document.createElement("script");
  25. script.src = uri;
  26. script.onload = resolve;
  27. document.head.appendChild(script);
  28. } else {
  29. nextDefineUri = uri;
  30. importScripts(uri);
  31. resolve();
  32. }
  33. })
  34. .then(() => {
  35. let promise = registry[uri];
  36. if (!promise) {
  37. throw new Error(`Module ${uri} didn’t register its module`);
  38. }
  39. return promise;
  40. })
  41. );
  42. };
  43. self.define = (depsNames, factory) => {
  44. const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
  45. if (registry[uri]) {
  46. // Module is already loading or loaded.
  47. return;
  48. }
  49. let exports = {};
  50. const require = depUri => singleRequire(depUri, uri);
  51. const specialDeps = {
  52. module: { uri },
  53. exports,
  54. require
  55. };
  56. registry[uri] = Promise.all(depsNames.map(
  57. depName => specialDeps[depName] || require(depName)
  58. )).then(deps => {
  59. factory(...deps);
  60. return exports;
  61. });
  62. };
  63. }
  64. <<<<<<< HEAD
  65. define(['./workbox-5357ef54'], function (workbox) {
  66. 'use strict';
  67. =======
  68. define(['./workbox-5357ef54'], (function (workbox) { 'use strict';
  69. >>>>>>> startLogin
  70. self.skipWaiting();
  71. workbox.clientsClaim();
  72. /**
  73. * The precacheAndRoute() method efficiently caches and responds to
  74. * requests for URLs in the manifest.
  75. * See https://goo.gl/S9QRab
  76. */
  77. <<<<<<< HEAD
  78. <<<<<<< HEAD
  79. workbox.precacheAndRoute(
  80. [
  81. {
  82. url: 'registerSW.js',
  83. revision: '3ca0b8505b4bec776b69afdba2768812'
  84. },
  85. {
  86. url: 'index.html',
  87. revision: '0.88abiq01ca8'
  88. }
  89. ],
  90. {}
  91. );
  92. =======
  93. =======
  94. >>>>>>> startLogin
  95. workbox.precacheAndRoute([{
  96. "url": "registerSW.js",
  97. "revision": "3ca0b8505b4bec776b69afdba2768812"
  98. }, {
  99. "url": "index.html",
  100. "revision": "0.menbt6dkbn8"
  101. }], {});
  102. <<<<<<< HEAD
  103. >>>>>>> startLogin
  104. =======
  105. >>>>>>> startLogin
  106. workbox.cleanupOutdatedCaches();
  107. workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
  108. allowlist: [/^\/$/]
  109. }));
  110. }));