chore: format code

This commit is contained in:
Ayo Ayco 2024-08-25 13:45:38 +02:00
parent 536372d895
commit e5d0a5e65c

View file

@ -57,12 +57,12 @@ export default function serviceWorker(options) {
} = options || {}; } = options || {};
const { const {
installing: installingFn = () => {}, installing: installingFn = () => { },
waiting: waitingFn = () => {}, waiting: waitingFn = () => { },
active: activeFn = () => {}, active: activeFn = () => { },
error: errorFn = () => {}, error: errorFn = () => { },
unsupported: unsupportedFn = () => {}, unsupported: unsupportedFn = () => { },
afterRegistration: afterRegistrationFn = () => {}, afterRegistration: afterRegistrationFn = () => { },
} = registrationHooks; } = registrationHooks;
/** /**
@ -114,15 +114,14 @@ export default function serviceWorker(options) {
injectScript('page', registrationScript); injectScript('page', registrationScript);
} }
}, },
'astro:config:done': async ({injectTypes, logger}) => { 'astro:config:done': async ({ injectTypes, logger }) => {
let injectedTypes = ` let injectedTypes = `
declare const __assets: string[]; declare const __assets: string[];
declare const __version: string; declare const __version: string;
declare const __prefix: string;` declare const __prefix: string;`
injectTypes({filename: 'caching.d.ts', content: injectedTypes}) injectTypes({ filename: 'caching.d.ts', content: injectedTypes })
}, },
'astro:build:ssr': ({ manifest }) => { 'astro:build:ssr': ({ manifest }) => {
if (output !== 'static') { if (output !== 'static') {
assets = manifest.assets assets = manifest.assets
} }
@ -194,7 +193,7 @@ declare const __prefix: string;`
logger.error(`Service worker script not found! ${swPath}`) logger.error(`Service worker script not found! ${swPath}`)
if (!swPath) { if (!swPath) {
logger.error(` logger.error(`
[${ASTROSW}] ERR: The 'path' option is required! [${ASTROSW}] ERR: The 'path' option is required!
[${ASTROSW}] INFO: Please see service worker options in https://ayco.io/gh/astro-sw#readme [${ASTROSW}] INFO: Please see service worker options in https://ayco.io/gh/astro-sw#readme
@ -206,10 +205,6 @@ declare const __prefix: string;`
const versionDeclaration = `const __version = ${JSON.stringify(assetCacheVersionID)};\n`; const versionDeclaration = `const __version = ${JSON.stringify(assetCacheVersionID)};\n`;
const prefixDeclaration = `const __prefix = ${JSON.stringify(assetCachePrefix)};\n`; const prefixDeclaration = `const __prefix = ${JSON.stringify(assetCachePrefix)};\n`;
/**
* TODO: allow importing in dev's sw.js by resolving imports
*/
const tempFile = `${swPath}.tmp.ts`; const tempFile = `${swPath}.tmp.ts`;
try { try {