feat: just commiting service worker

This commit is contained in:
wonderlandpark 2021-05-17 20:27:06 +09:00
parent de254f914a
commit d3e2e935c8
7 changed files with 2877 additions and 14 deletions

14
.gitignore vendored
View File

@ -42,16 +42,4 @@ yarn-error.log*
package-lock.json
# sub module
api-docs/
# next-pwa
public/precache.*.*.js
public/sw.js
public/workbox-*.js
public/worker-*.js
public/fallback-*.js
public/precache.*.*.js.map
public/sw.js.map
public/workbox-*.js.map
public/worker-*.js.map
public/fallback-*.js
api-docs/

View File

@ -5,7 +5,7 @@ const VERSION = require('./package.json').version
const NextConfig = {
pwa: {
dest: 'public',
disable: process.env.NODE_ENV !== 'production',
register: false
},
env: {

View File

@ -0,0 +1,36 @@
/******/ (() => { // webpackBootstrap
/******/ "use strict";
var __webpack_exports__ = {};
self.fallback = async request => {
// https://developer.mozilla.org/en-US/docs/Web/API/RequestDestination
switch (request.destination) {
case 'document':
if (true) return caches.match("/_offline", {
ignoreSearch: true
});
case 'image':
if (false) {}
case 'audio':
if (false) {}
case 'video':
if (false) {}
case 'font':
if (false) {}
case '':
if (false) {}
default:
return Response.error();
}
;
};
/******/ })()
;

136
public/sw.js Normal file
View File

@ -0,0 +1,136 @@
/**
* Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// If the loader is already loaded, just stop.
if (!self.define) {
const singleRequire = name => {
if (name !== 'require') {
name = name + '.js';
}
let promise = Promise.resolve();
if (!registry[name]) {
promise = new Promise(async resolve => {
if ("document" in self) {
const script = document.createElement("script");
script.src = name;
document.head.appendChild(script);
script.onload = resolve;
} else {
importScripts(name);
resolve();
}
});
}
return promise.then(() => {
if (!registry[name]) {
throw new Error(`Module ${name} didnt register its module`);
}
return registry[name];
});
};
const require = (names, resolve) => {
Promise.all(names.map(singleRequire))
.then(modules => resolve(modules.length === 1 ? modules[0] : modules));
};
const registry = {
require: Promise.resolve(require)
};
self.define = (moduleName, depsNames, factory) => {
if (registry[moduleName]) {
// Module is already loading or loaded.
return;
}
registry[moduleName] = Promise.resolve().then(() => {
let exports = {};
const module = {
uri: location.origin + moduleName.slice(1)
};
return Promise.all(
depsNames.map(depName => {
switch(depName) {
case "exports":
return exports;
case "module":
return module;
default:
return singleRequire(depName);
}
})
).then(deps => {
const facValue = factory(...deps);
if(!exports.default) {
exports.default = facValue;
}
return exports;
});
});
};
}
define("./sw.js",['./workbox-6b19f60b'], function (workbox) { 'use strict';
/**
* Welcome to your Workbox-powered service worker!
*
* You'll need to register this file in your web app.
* 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("fallback-development.js");
self.skipWaiting();
workbox.clientsClaim();
workbox.registerRoute("/", new workbox.NetworkFirst({
"cacheName": "start-url",
plugins: [{
cacheWillUpdate: async ({
request,
response,
event,
state
}) => {
if (response && response.type === 'opaqueredirect') {
return new Response(response.body, {
status: 200,
statusText: 'OK',
headers: response.headers
});
}
return response;
}
}, {
handlerDidError: async ({
request
}) => self.fallback(request)
}]
}), 'GET');
workbox.registerRoute(/.*/i, new workbox.NetworkOnly({
"cacheName": "dev",
plugins: [{
handlerDidError: async ({
request
}) => self.fallback(request)
}]
}), 'GET');
});
//# sourceMappingURL=sw.js.map

1
public/sw.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"sw.js","sources":["../../../../private/var/folders/s2/c5ly4ybd1k92c69fqc4_50rm0000gn/T/5fbbbe185f17dcb9e5c6150af5a7b636/sw.js"],"sourcesContent":["import {registerRoute as workbox_routing_registerRoute} from '/Users/wonderlandpark/Workspace/koreanbots/node_modules/workbox-routing/registerRoute.mjs';\nimport {NetworkFirst as workbox_strategies_NetworkFirst} from '/Users/wonderlandpark/Workspace/koreanbots/node_modules/workbox-strategies/NetworkFirst.mjs';\nimport {NetworkOnly as workbox_strategies_NetworkOnly} from '/Users/wonderlandpark/Workspace/koreanbots/node_modules/workbox-strategies/NetworkOnly.mjs';\nimport {clientsClaim as workbox_core_clientsClaim} from '/Users/wonderlandpark/Workspace/koreanbots/node_modules/workbox-core/clientsClaim.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\nimportScripts(\n \"fallback-development.js\"\n);\n\n\n\n\n\n\n\nself.skipWaiting();\n\nworkbox_core_clientsClaim();\n\n\n\nworkbox_routing_registerRoute(\"/\", new workbox_strategies_NetworkFirst({ \"cacheName\":\"start-url\", plugins: [{ cacheWillUpdate: async ({request, response, event, state}) => { if (response && response.type === 'opaqueredirect') { return new Response(response.body, {status: 200, statusText: 'OK', headers: response.headers}); } return response; } }, { handlerDidError: async ({request}) => self.fallback(request) }] }), 'GET');\nworkbox_routing_registerRoute(/.*/i, new workbox_strategies_NetworkOnly({ \"cacheName\":\"dev\", plugins: [{ handlerDidError: async ({request}) => self.fallback(request) }] }), 'GET');\n\n\n\n\n"],"names":["importScripts","self","skipWaiting","workbox_core_clientsClaim","workbox_routing_registerRoute","workbox_strategies_NetworkFirst","plugins","cacheWillUpdate","request","response","event","state","type","Response","body","status","statusText","headers","handlerDidError","fallback","workbox_strategies_NetworkOnly"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGgJ;EAChJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAGAA,aAAa,CACX,yBADW,CAAb;EAUAC,IAAI,CAACC,WAAL;AAEAC,sBAAyB;AAIzBC,uBAA6B,CAAC,GAAD,EAAM,IAAIC,oBAAJ,CAAoC;EAAE,eAAY,WAAd;EAA2BC,EAAAA,OAAO,EAAE,CAAC;EAAEC,IAAAA,eAAe,EAAE,OAAO;EAACC,MAAAA,OAAD;EAAUC,MAAAA,QAAV;EAAoBC,MAAAA,KAApB;EAA2BC,MAAAA;EAA3B,KAAP,KAA6C;EAAE,UAAIF,QAAQ,IAAIA,QAAQ,CAACG,IAAT,KAAkB,gBAAlC,EAAoD;EAAE,eAAO,IAAIC,QAAJ,CAAaJ,QAAQ,CAACK,IAAtB,EAA4B;EAACC,UAAAA,MAAM,EAAE,GAAT;EAAcC,UAAAA,UAAU,EAAE,IAA1B;EAAgCC,UAAAA,OAAO,EAAER,QAAQ,CAACQ;EAAlD,SAA5B,CAAP;EAAiG;;EAAC,aAAOR,QAAP;EAAkB;EAA5O,GAAD,EAAiP;EAAES,IAAAA,eAAe,EAAE,OAAO;EAACV,MAAAA;EAAD,KAAP,KAAqBP,IAAI,CAACkB,QAAL,CAAcX,OAAd;EAAxC,GAAjP;EAApC,CAApC,CAAN,EAAqY,KAArY,CAA7B;AACAJ,uBAA6B,CAAC,KAAD,EAAQ,IAAIgB,mBAAJ,CAAmC;EAAE,eAAY,KAAd;EAAqBd,EAAAA,OAAO,EAAE,CAAC;EAAEY,IAAAA,eAAe,EAAE,OAAO;EAACV,MAAAA;EAAD,KAAP,KAAqBP,IAAI,CAACkB,QAAL,CAAcX,OAAd;EAAxC,GAAD;EAA9B,CAAnC,CAAR,EAAgJ,KAAhJ,CAA7B;;"}

2701
public/workbox-6b19f60b.js Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long