Skip to content

Commit

Permalink
docs: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Gomah committed Feb 16, 2024
1 parent a94f3fb commit 9d98736
Show file tree
Hide file tree
Showing 8 changed files with 7,727 additions and 7,146 deletions.
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.5.0.cjs
yarnPath: .yarn/releases/yarn-4.1.0.cjs
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"generate": "nuxt generate"
},
"dependencies": {
"@nuxt/content-theme-docs": "0.11.0",
"@nuxt/content-theme-docs": "0.11.1",
"@nuxtjs/tailwindcss": "6.11.4",
"nuxt": "2.17.3"
}
}
123 changes: 110 additions & 13 deletions docs/static/sw.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,114 @@
// THIS FILE SHOULD NOT BE VERSION CONTROLLED
const options = {"workboxURL":"https://cdn.jsdelivr.net/npm/workbox-cdn@5.1.4/workbox/workbox-sw.js","importScripts":[],"config":{"debug":false},"cacheOptions":{"cacheId":"nuxt-shopify-docs-prod","directoryIndex":"/","revision":"uNrks38L0Iyz"},"clientsClaim":true,"skipWaiting":true,"cleanupOutdatedCaches":true,"offlineAnalytics":false,"preCaching":[{"revision":"uNrks38L0Iyz","url":"/?standalone=true"}],"runtimeCaching":[{"urlPattern":"/_nuxt/","handler":"CacheFirst","method":"GET","strategyPlugins":[]},{"urlPattern":"/","handler":"NetworkFirst","method":"GET","strategyPlugins":[]}],"offlinePage":null,"pagesURLPattern":"/","offlineStrategy":"NetworkFirst"}

// https://github.com/NekR/self-destroying-sw
importScripts(...[options.workboxURL, ...options.importScripts])

self.addEventListener('install', function (e) {
self.skipWaiting()
})
initWorkbox(workbox, options)
workboxExtensions(workbox, options)
precacheAssets(workbox, options)
cachingExtensions(workbox, options)
runtimeCaching(workbox, options)
offlinePage(workbox, options)
routingExtensions(workbox, options)

self.addEventListener('activate', function (e) {
self.registration.unregister()
.then(function () {
return self.clients.matchAll()
})
.then(function (clients) {
clients.forEach(client => client.navigate(client.url))
function getProp(obj, prop) {
return prop.split('.').reduce((p, c) => p[c], obj)
}

function initWorkbox(workbox, options) {
if (options.config) {
// Set workbox config
workbox.setConfig(options.config)
}

if (options.cacheNames) {
// Set workbox cache names
workbox.core.setCacheNameDetails(options.cacheNames)
}

if (options.clientsClaim) {
// Start controlling any existing clients as soon as it activates
workbox.core.clientsClaim()
}

if (options.skipWaiting) {
workbox.core.skipWaiting()
}

if (options.cleanupOutdatedCaches) {
workbox.precaching.cleanupOutdatedCaches()
}

if (options.offlineAnalytics) {
// Enable offline Google Analytics tracking
workbox.googleAnalytics.initialize()
}
}

function precacheAssets(workbox, options) {
if (options.preCaching.length) {
workbox.precaching.precacheAndRoute(options.preCaching, options.cacheOptions)
}
}


function runtimeCaching(workbox, options) {
const requestInterceptor = {
requestWillFetch({ request }) {
if (request.cache === 'only-if-cached' && request.mode === 'no-cors') {
return new Request(request.url, { ...request, cache: 'default', mode: 'no-cors' })
}
return request
},
fetchDidFail(ctx) {
ctx.error.message =
'[workbox] Network request for ' + ctx.request.url + ' threw an error: ' + ctx.error.message
console.error(ctx.error, 'Details:', ctx)
},
handlerDidError(ctx) {
ctx.error.message =
`[workbox] Network handler threw an error: ` + ctx.error.message
console.error(ctx.error, 'Details:', ctx)
return null
}
}

for (const entry of options.runtimeCaching) {
const urlPattern = new RegExp(entry.urlPattern)
const method = entry.method || 'GET'

const plugins = (entry.strategyPlugins || [])
.map(p => new (getProp(workbox, p.use))(...p.config))

plugins.unshift(requestInterceptor)

const strategyOptions = { ...entry.strategyOptions, plugins }

const strategy = new workbox.strategies[entry.handler](strategyOptions)

workbox.routing.registerRoute(urlPattern, strategy, method)
}
}

function offlinePage(workbox, options) {
if (options.offlinePage) {
// Register router handler for offlinePage
workbox.routing.registerRoute(new RegExp(options.pagesURLPattern), ({ request, event }) => {
const strategy = new workbox.strategies[options.offlineStrategy]
return strategy
.handle({ request, event })
.catch(() => caches.match(options.offlinePage))
})
})
}
}

function workboxExtensions(workbox, options) {

}

function cachingExtensions(workbox, options) {

}

function routingExtensions(workbox, options) {

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@
"ts-node": "10.9.2",
"typescript": "5.3.3"
},
"packageManager": "yarn@3.5.0"
"packageManager": "yarn@4.1.0"
}
Loading

0 comments on commit 9d98736

Please sign in to comment.