feat: docs rehaul, fix missing context in console, quickstarts (#1212)
* onboarding components, routing, steps
* onboarding component, toc
* fix onboarding mixin
* header
* refactor docs
* fix layout
* cleanup routing
* docs routing
* fix conventions
* de en routing
* docs, guide contents, nav
* rem i18n support
* fix routing from docs
* rollup onwarn changes, preload
* update svelte plugin, update rollup config
* move docs
* revert img style, remove code table
* rem de completely
* rollup optim, template
* angular quickstart, quickstart overview page, update deps
* fix link
* pack, slug
* prefetch binding, hidden links
* export log
* guards route ch
* fix homepage
* angular docs
* docs
* resolve fsh
* overview
* docs
* docs
* packages fix race condition
* nav, home link
* add vue, aspnet
* doc optimizations
* embed status pal
* angular guide
* angular guide
* dotnet, angular guide
* viewbox
* typo
* block onboarding route for non iam writers
* set links from component data
* fix: fetch org context in guard, more main cnt (#1192)
* change get started guide, fix code blockquotes, typos
* flutter guide
* h2 spacing
* highlight strong
* plus
* rm start sublinks
* add proxy quickstart
* regex
* prevent outside click, fix project grant write
Co-authored-by: Florian Forster <florian@caos.ch>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-02-16 16:59:18 +01:00
|
|
|
import { files, shell, timestamp } from '@sapper/service-worker';
|
2020-08-11 09:53:09 +02:00
|
|
|
|
feat: docs rehaul, fix missing context in console, quickstarts (#1212)
* onboarding components, routing, steps
* onboarding component, toc
* fix onboarding mixin
* header
* refactor docs
* fix layout
* cleanup routing
* docs routing
* fix conventions
* de en routing
* docs, guide contents, nav
* rem i18n support
* fix routing from docs
* rollup onwarn changes, preload
* update svelte plugin, update rollup config
* move docs
* revert img style, remove code table
* rem de completely
* rollup optim, template
* angular quickstart, quickstart overview page, update deps
* fix link
* pack, slug
* prefetch binding, hidden links
* export log
* guards route ch
* fix homepage
* angular docs
* docs
* resolve fsh
* overview
* docs
* docs
* packages fix race condition
* nav, home link
* add vue, aspnet
* doc optimizations
* embed status pal
* angular guide
* angular guide
* dotnet, angular guide
* viewbox
* typo
* block onboarding route for non iam writers
* set links from component data
* fix: fetch org context in guard, more main cnt (#1192)
* change get started guide, fix code blockquotes, typos
* flutter guide
* h2 spacing
* highlight strong
* plus
* rm start sublinks
* add proxy quickstart
* regex
* prevent outside click, fix project grant write
Co-authored-by: Florian Forster <florian@caos.ch>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-02-16 16:59:18 +01:00
|
|
|
// eslint-disable-next-line import/no-unresolved
|
2020-08-11 09:53:09 +02:00
|
|
|
const ASSETS = `cache${timestamp}`;
|
|
|
|
|
|
|
|
|
|
// `shell` is an array of all the files generated by the bundler,
|
|
|
|
|
// `files` is an array of everything in the `static` directory
|
|
|
|
|
const to_cache = shell.concat(files);
|
|
|
|
|
const cached = new Set(to_cache);
|
|
|
|
|
|
|
|
|
|
self.addEventListener('install', event => {
|
2020-11-11 11:50:38 +01:00
|
|
|
event.waitUntil(
|
|
|
|
|
caches
|
|
|
|
|
.open(ASSETS)
|
|
|
|
|
.then(cache => cache.addAll(to_cache))
|
|
|
|
|
.then(() => {
|
|
|
|
|
self.skipWaiting();
|
|
|
|
|
})
|
|
|
|
|
);
|
2020-08-11 09:53:09 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.addEventListener('activate', event => {
|
2020-11-11 11:50:38 +01:00
|
|
|
event.waitUntil(
|
|
|
|
|
caches.keys().then(async keys => {
|
|
|
|
|
// delete old caches
|
|
|
|
|
for (const key of keys) {
|
|
|
|
|
if (key !== ASSETS) await caches.delete(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.clients.claim();
|
|
|
|
|
})
|
|
|
|
|
);
|
2020-08-11 09:53:09 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.addEventListener('fetch', event => {
|
2020-11-11 11:50:38 +01:00
|
|
|
if (event.request.method !== 'GET' || event.request.headers.has('range')) return;
|
|
|
|
|
|
|
|
|
|
const url = new URL(event.request.url);
|
|
|
|
|
|
|
|
|
|
// don't try to handle e.g. data: URIs
|
|
|
|
|
if (!url.protocol.startsWith('http')) return;
|
|
|
|
|
|
|
|
|
|
// ignore dev server requests
|
|
|
|
|
if (url.hostname === self.location.hostname && url.port !== self.location.port) return;
|
|
|
|
|
|
|
|
|
|
// always serve static files and bundler-generated assets from cache
|
|
|
|
|
if (url.host === self.location.host && cached.has(url.pathname)) {
|
|
|
|
|
event.respondWith(caches.match(event.request));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// for pages, you might want to serve a shell `service-worker-index.html` file,
|
|
|
|
|
// which Sapper has generated for you. It's not right for every
|
|
|
|
|
// app, but if it's right for yours then uncomment this section
|
feat: docs rehaul, fix missing context in console, quickstarts (#1212)
* onboarding components, routing, steps
* onboarding component, toc
* fix onboarding mixin
* header
* refactor docs
* fix layout
* cleanup routing
* docs routing
* fix conventions
* de en routing
* docs, guide contents, nav
* rem i18n support
* fix routing from docs
* rollup onwarn changes, preload
* update svelte plugin, update rollup config
* move docs
* revert img style, remove code table
* rem de completely
* rollup optim, template
* angular quickstart, quickstart overview page, update deps
* fix link
* pack, slug
* prefetch binding, hidden links
* export log
* guards route ch
* fix homepage
* angular docs
* docs
* resolve fsh
* overview
* docs
* docs
* packages fix race condition
* nav, home link
* add vue, aspnet
* doc optimizations
* embed status pal
* angular guide
* angular guide
* dotnet, angular guide
* viewbox
* typo
* block onboarding route for non iam writers
* set links from component data
* fix: fetch org context in guard, more main cnt (#1192)
* change get started guide, fix code blockquotes, typos
* flutter guide
* h2 spacing
* highlight strong
* plus
* rm start sublinks
* add proxy quickstart
* regex
* prevent outside click, fix project grant write
Co-authored-by: Florian Forster <florian@caos.ch>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-02-16 16:59:18 +01:00
|
|
|
/*
|
|
|
|
|
if (url.origin === self.origin && routes.find(route => route.pattern.test(url.pathname))) {
|
|
|
|
|
event.respondWith(caches.match('/service-worker-index.html'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
*/
|
2020-11-11 11:50:38 +01:00
|
|
|
|
|
|
|
|
if (event.request.cache === 'only-if-cached') return;
|
|
|
|
|
|
|
|
|
|
// for everything else, try the network first, falling back to
|
|
|
|
|
// cache if the user is offline. (If the pages never change, you
|
|
|
|
|
// might prefer a cache-first approach to a network-first one.)
|
|
|
|
|
event.respondWith(
|
|
|
|
|
caches
|
|
|
|
|
.open(`offline${timestamp}`)
|
|
|
|
|
.then(async cache => {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(event.request);
|
|
|
|
|
cache.put(event.request, response.clone());
|
|
|
|
|
return response;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const response = await cache.match(event.request);
|
|
|
|
|
if (response) return response;
|
|
|
|
|
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
feat: docs rehaul, fix missing context in console, quickstarts (#1212)
* onboarding components, routing, steps
* onboarding component, toc
* fix onboarding mixin
* header
* refactor docs
* fix layout
* cleanup routing
* docs routing
* fix conventions
* de en routing
* docs, guide contents, nav
* rem i18n support
* fix routing from docs
* rollup onwarn changes, preload
* update svelte plugin, update rollup config
* move docs
* revert img style, remove code table
* rem de completely
* rollup optim, template
* angular quickstart, quickstart overview page, update deps
* fix link
* pack, slug
* prefetch binding, hidden links
* export log
* guards route ch
* fix homepage
* angular docs
* docs
* resolve fsh
* overview
* docs
* docs
* packages fix race condition
* nav, home link
* add vue, aspnet
* doc optimizations
* embed status pal
* angular guide
* angular guide
* dotnet, angular guide
* viewbox
* typo
* block onboarding route for non iam writers
* set links from component data
* fix: fetch org context in guard, more main cnt (#1192)
* change get started guide, fix code blockquotes, typos
* flutter guide
* h2 spacing
* highlight strong
* plus
* rm start sublinks
* add proxy quickstart
* regex
* prevent outside click, fix project grant write
Co-authored-by: Florian Forster <florian@caos.ch>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-02-16 16:59:18 +01:00
|
|
|
});
|