@ducanh2912/next-pwa
Advanced tools
Comparing version 10.2.5 to 10.2.6
@@ -1,1 +0,14 @@ | ||
self.fallback=async _=>{let{destination:e,url:A}=_,s={document:process.env.__PWA_FALLBACK_DOCUMENT__,image:process.env.__PWA_FALLBACK_IMAGE__,audio:process.env.__PWA_FALLBACK_AUDIO__,video:process.env.__PWA_FALLBACK_VIDEO__,font:process.env.__PWA_FALLBACK_FONT__}[e];return s?caches.match(s,{ignoreSearch:!0}):""===e&&process.env.__PWA_FALLBACK_DATA__&&A.match(/\/_next\/data\/.+\/.+\.json$/i)?caches.match(process.env.__PWA_FALLBACK_DATA__,{ignoreSearch:!0}):Response.error()}; | ||
self.fallback = async (_)=>{ | ||
let { destination: e, url: A } = _, s = { | ||
document: process.env.__PWA_FALLBACK_DOCUMENT__, | ||
image: process.env.__PWA_FALLBACK_IMAGE__, | ||
audio: process.env.__PWA_FALLBACK_AUDIO__, | ||
video: process.env.__PWA_FALLBACK_VIDEO__, | ||
font: process.env.__PWA_FALLBACK_FONT__ | ||
}[e]; | ||
return s ? caches.match(s, { | ||
ignoreSearch: !0 | ||
}) : "" === e && process.env.__PWA_FALLBACK_DATA__ && A.match(/\/_next\/data\/.+\/.+\.json$/i) ? caches.match(process.env.__PWA_FALLBACK_DATA__, { | ||
ignoreSearch: !0 | ||
}) : Response.error(); | ||
}; |
1038
dist/index.js
@@ -1,2 +0,1036 @@ | ||
import e$1 from'path';import {CleanWebpackPlugin}from'clean-webpack-plugin';import {createRequire}from'module';import e$2 from'fs';import t$3 from'process';import e$3 from'os';import o$1 from'tty';import {coerce,lt}from'semver';import {fileURLToPath}from'url';import s$1 from'fast-glob';import e$4 from'crypto';import o$2 from'workbox-webpack-plugin';const findFirstTruthy=(t,r)=>{for(let e of t){let t=r(e);if(t)return t}};let r$4=createRequire(import.meta.url);const getPackageVersion=e=>{try{return r$4(`${e}/package.json`).version}catch{return}};const loadTSConfig=(n,e)=>{try{let i=findFirstTruthy([e??"tsconfig.json","jsconfig.json"],o=>{let e=e$1.join(n,o);return e$2.existsSync(e)?e:void 0});if(!i)return;return JSON.parse(e$2.readFileSync(i,"utf-8"))}catch{return}};let e=(e=0)=>r=>`\u001B[${r+e}m`,r$3=(e=0)=>r=>`\u001B[${38+e};5;${r}m`,o=(e=0)=>(r,o,t)=>`\u001B[${38+e};2;${r};${o};${t}m`,t$2={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(t$2.modifier);const foregroundColorNames=Object.keys(t$2.color);const backgroundColorNames=Object.keys(t$2.bgColor);[...foregroundColorNames,...backgroundColorNames];let n$2=function(){let n=new Map;for(let[e,r]of Object.entries(t$2)){for(let[e,o]of Object.entries(r))t$2[e]={open:`\u001B[${o[0]}m`,close:`\u001B[${o[1]}m`},r[e]=t$2[e],n.set(o[0],o[1]);Object.defineProperty(t$2,e,{value:r,enumerable:!1});}return Object.defineProperty(t$2,"codes",{value:n,enumerable:!1}),t$2.color.close="\x1b[39m",t$2.bgColor.close="\x1b[49m",t$2.color.ansi=e(),t$2.color.ansi256=r$3(),t$2.color.ansi16m=o(),t$2.bgColor.ansi=e(10),t$2.bgColor.ansi256=r$3(10),t$2.bgColor.ansi16m=o(10),Object.defineProperties(t$2,{rgbToAnsi256:{value:(e,r,o)=>e===r&&r===o?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return [0,0,0];let[o]=r;3===o.length&&(o=[...o].map(e=>e+e).join(""));let t=Number.parseInt(o,16);return [t>>16&255,t>>8&255,255&t]},enumerable:!1},hexToAnsi256:{value:e=>t$2.rgbToAnsi256(...t$2.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let r,o,t;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)o=r=((e-232)*10+8)/255,t=r;else {let n=(e-=16)%36;r=Math.floor(e/36)/5,o=Math.floor(n/6)/5,t=n%6/5;}let n=2*Math.max(r,o,t);if(0===n)return 30;let l=30+(Math.round(t)<<2|Math.round(o)<<1|Math.round(r));return 2===n&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,r,o)=>t$2.ansi256ToAnsi(t$2.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>t$2.ansi256ToAnsi(t$2.hexToAnsi256(e)),enumerable:!1}}),t$2}();let r$2;function i$3(r,e=globalThis.Deno?globalThis.Deno.args:t$3.argv){let o=r.startsWith("-")?"":1===r.length?"-":"--",i=e.indexOf(o+r),n=e.indexOf("--");return -1!==i&&(-1===n||i<n)}let{env:n$1}=t$3;i$3("no-color")||i$3("no-colors")||i$3("color=false")||i$3("color=never")?r$2=0:(i$3("color")||i$3("colors")||i$3("color=true")||i$3("color=always"))&&(r$2=1);function createSupportsColor(o,l={}){var s;return 0!==(s=function(o,{streamIsTTY:l,sniffFlags:s=!0}={}){let u=function(){if("FORCE_COLOR"in n$1)return "true"===n$1.FORCE_COLOR?1:"false"===n$1.FORCE_COLOR?0:0===n$1.FORCE_COLOR.length?1:Math.min(Number.parseInt(n$1.FORCE_COLOR,10),3)}();void 0!==u&&(r$2=u);let R=s?r$2:u;if(0===R)return 0;if(s){if(i$3("color=16m")||i$3("color=full")||i$3("color=truecolor"))return 3;if(i$3("color=256"))return 2}if("TF_BUILD"in n$1&&"AGENT_NAME"in n$1)return 1;if(o&&!l&&void 0===R)return 0;let T=R||0;if("dumb"===n$1.TERM)return T;if("win32"===t$3.platform){let r=e$3.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in n$1)return "GITHUB_ACTIONS"in n$1||"GITEA_ACTIONS"in n$1?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(r=>r in n$1)||"codeship"===n$1.CI_NAME?1:T;if("TEAMCITY_VERSION"in n$1)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n$1.TEAMCITY_VERSION)?1:0;if("truecolor"===n$1.COLORTERM||"xterm-kitty"===n$1.TERM)return 3;if("TERM_PROGRAM"in n$1){let r=Number.parseInt((n$1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n$1.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return /-256(color)?$/i.test(n$1.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n$1.TERM)||"COLORTERM"in n$1?1:T}(o,{streamIsTTY:o&&o.isTTY,...l}))&&{level:s,hasBasic:!0,has256:s>=2,has16m:s>=3}}let l$2={stdout:createSupportsColor({isTTY:o$1.isatty(1)}),stderr:createSupportsColor({isTTY:o$1.isatty(2)})};function stringReplaceAll(e,n,i){let t=e.indexOf(n);if(-1===t)return e;let l=n.length,r=0,c="";do c+=e.slice(r,t)+n+i,r=t+l,t=e.indexOf(n,r);while(-1!==t)return c+e.slice(r)}function stringEncaseCRLFWithFirstIndex(e,n,i,t){let l=0,r="";do{let c="\r"===e[t-1];r+=e.slice(l,c?t-1:t)+n+(c?"\r\n":"\n")+i,l=t+1,t=e.indexOf("\n",l);}while(-1!==t)return r+e.slice(l)}let{stdout:l$1,stderr:s}=l$2,i$2=Symbol("GENERATOR"),n=Symbol("STYLER"),a$1=Symbol("IS_EMPTY"),u=["ansi","ansi","ansi256","ansi16m"],p$2=Object.create(null),c=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let o=l$1?l$1.level:0;e.level=void 0===t.level?o:t.level;};let f=e=>{let t=(...e)=>e.join(" ");return c(t,e),Object.setPrototypeOf(t,b.prototype),t};function b(e){return f(e)}for(let[t,o]of(Object.setPrototypeOf(b.prototype,Function.prototype),Object.entries(n$2)))p$2[t]={get(){let e=v(this,h(o.open,o.close,this[n]),this[a$1]);return Object.defineProperty(this,t,{value:e}),e}};p$2.visible={get(){let e=v(this,this[n],!0);return Object.defineProperty(this,"visible",{value:e}),e}};let d=(t,o,r,...l)=>"rgb"===t?"ansi16m"===o?n$2[r].ansi16m(...l):"ansi256"===o?n$2[r].ansi256(n$2.rgbToAnsi256(...l)):n$2[r].ansi(n$2.rgbToAnsi(...l)):"hex"===t?d("rgb",o,r,...n$2.hexToRgb(...l)):n$2[r][t](...l);for(let t of ["rgb","hex","ansi256"])p$2[t]={get(){let{level:o}=this;return function(...r){return v(this,h(d(t,u[o],"color",...r),n$2.color.close,this[n]),this[a$1])}}},p$2["bg"+t[0].toUpperCase()+t.slice(1)]={get(){let{level:o}=this;return function(...r){return v(this,h(d(t,u[o],"bgColor",...r),n$2.bgColor.close,this[n]),this[a$1])}}};let m=Object.defineProperties(()=>{},{...p$2,level:{enumerable:!0,get(){return this[i$2].level},set(e){this[i$2].level=e;}}}),h=(e,t,o)=>{let r,l;return void 0===o?(r=e,l=t):(r=o.openAll+e,l=t+o.closeAll),{open:e,close:t,openAll:r,closeAll:l,parent:o}},v=(e,t,o)=>{let r=(...e)=>g(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,m),r[i$2]=e,r[n]=t,r[a$1]=o,r},g=(e,t)=>{if(e.level<=0||!t)return e[a$1]?"":t;let l=e[n];if(void 0===l)return t;let{openAll:s,closeAll:i}=l;if(t.includes("\x1b"))for(;void 0!==l;)t=stringReplaceAll(t,l.close,l.open),l=l.parent;let u=t.indexOf("\n");return -1!==u&&(t=stringEncaseCRLFWithFirstIndex(t,i,s,u)),s+t+i};Object.defineProperties(b.prototype,p$2);let y=f(void 0);f({level:s?s.level:0});var r$1 = y;let a=coerce(getPackageVersion("next")),t$1=!!a&<(a,"13.4.1"),w=!!a&<(a,"13.4.20"),i$1={wait:"log",error:"error",warn:"warn",info:"log",event:"log"},l=t$1?{wait:`${r$1.cyan("wait")} - (PWA)`,error:`${r$1.red("error")} - (PWA)`,warn:`${r$1.yellow("warn")} - (PWA)`,info:`${r$1.cyan("info")} - (PWA)`,event:`${r$1.cyan("info")} - (PWA)`}:w?{wait:`- ${r$1.cyan("wait")} (pwa)`,error:`- ${r$1.red("error")} (pwa)`,warn:`- ${r$1.yellow("warn")} (pwa)`,info:`- ${r$1.cyan("info")} (pwa)`,event:`- ${r$1.cyan("info")} (pwa)`}:{wait:`${r$1.white(r$1.bold("\u25CB"))} (pwa)`,error:`${r$1.red(r$1.bold("X"))} (pwa)`,warn:`${r$1.yellow(r$1.bold("\u26A0"))} (pwa)`,info:`${r$1.white(r$1.bold("\u25CB"))} (pwa)`,event:`${r$1.green(r$1.bold("\u2713"))} (pwa)`},p$1=(r,...o)=>{let e=i$1[r],n=l[r];if(w)return console[e](n,...o);(""===o[0]||void 0===o[0])&&1===o.length&&o.shift(),0===o.length?console[e](""):console[e](` ${n}`,...o);};const info=(...r)=>{p$1("info",...r);};const event=(...r)=>{p$1("event",...r);};const normalizePathSep=e=>e.replace(/\\/g,"/");function relativeToOutputPath$1(e,r){return e$1.resolve(r)===e$1.normalize(r)?normalizePathSep(e$1.relative(e.options.output.path,r)):normalizePathSep(r)}var t = [{urlPattern:/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,handler:"CacheFirst",options:{cacheName:"google-fonts-webfonts",expiration:{maxEntries:4,maxAgeSeconds:31536e3}}},{urlPattern:/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,handler:"StaleWhileRevalidate",options:{cacheName:"google-fonts-stylesheets",expiration:{maxEntries:4,maxAgeSeconds:604800}}},{urlPattern:/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,handler:"StaleWhileRevalidate",options:{cacheName:"static-font-assets",expiration:{maxEntries:4,maxAgeSeconds:604800}}},{urlPattern:/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,handler:"StaleWhileRevalidate",options:{cacheName:"static-image-assets",expiration:{maxEntries:64,maxAgeSeconds:2592e3}}},{urlPattern:/\/_next\/static.+\.js$/i,handler:"CacheFirst",options:{cacheName:"next-static-js-assets",expiration:{maxEntries:64,maxAgeSeconds:86400}}},{urlPattern:/\/_next\/image\?url=.+$/i,handler:"StaleWhileRevalidate",options:{cacheName:"next-image",expiration:{maxEntries:64,maxAgeSeconds:86400}}},{urlPattern:/\.(?:mp3|wav|ogg)$/i,handler:"CacheFirst",options:{rangeRequests:!0,cacheName:"static-audio-assets",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:/\.(?:mp4|webm)$/i,handler:"CacheFirst",options:{rangeRequests:!0,cacheName:"static-video-assets",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:/\.(?:js)$/i,handler:"StaleWhileRevalidate",options:{cacheName:"static-js-assets",expiration:{maxEntries:48,maxAgeSeconds:86400}}},{urlPattern:/\.(?:css|less)$/i,handler:"StaleWhileRevalidate",options:{cacheName:"static-style-assets",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:/\/_next\/data\/.+\/.+\.json$/i,handler:"StaleWhileRevalidate",options:{cacheName:"next-data",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:/\.(?:json|xml|csv)$/i,handler:"NetworkFirst",options:{cacheName:"static-data-assets",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:({sameOrigin:e,url:{pathname:t}})=>!(!e||t.startsWith("/api/auth/callback"))&&!!t.startsWith("/api/"),handler:"NetworkFirst",method:"GET",options:{cacheName:"apis",expiration:{maxEntries:16,maxAgeSeconds:86400},networkTimeoutSeconds:10}},{urlPattern:({request:e,url:{pathname:t},sameOrigin:a})=>"1"===e.headers.get("RSC")&&"1"===e.headers.get("Next-Router-Prefetch")&&a&&!t.startsWith("/api/"),handler:"NetworkFirst",options:{cacheName:"pages-rsc-prefetch",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:({request:e,url:{pathname:t},sameOrigin:a})=>"1"===e.headers.get("RSC")&&a&&!t.startsWith("/api/"),handler:"NetworkFirst",options:{cacheName:"pages-rsc",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:({url:{pathname:e},sameOrigin:t})=>t&&!e.startsWith("/api/"),handler:"NetworkFirst",options:{cacheName:"pages",expiration:{maxEntries:32,maxAgeSeconds:86400}}},{urlPattern:({sameOrigin:e})=>!e,handler:"NetworkFirst",options:{cacheName:"cross-origin",expiration:{maxEntries:32,maxAgeSeconds:3600},networkTimeoutSeconds:10}}];const overrideAfterCalledMethod=e=>{Object.defineProperty(e,"alreadyCalled",{get:()=>!1,set(){}});};const isInjectManifestConfig=e=>void 0!==e&&"string"==typeof e.swSrc;const getFileHash=r=>e$4.createHash("md5").update(e$2.readFileSync(r)).digest("hex");const getContentHash=(e,t)=>t?"development":getFileHash(e).slice(0,16);const getDefaultDocumentPage=(f,t)=>{let n=findFirstTruthy(["pages","src/pages"],o=>(o=e$1.join(f,o),e$2.existsSync(o)?o:void 0)),s=findFirstTruthy(["app","src/app"],o=>(o=e$1.join(f,o),e$2.existsSync(o)?o:void 0));if(n||s)for(let o of t){if(s){let f=e$1.join(s,`~offline/page.${o}`);if(e$2.existsSync(f))return "/~offline"}if(n){let f=e$1.join(n,`_offline.${o}`);if(f&&e$2.existsSync(f))return "/_offline"}}};let p=fileURLToPath(new URL(".",import.meta.url));const parseOptions=(t,i,r,{disable:p=!1,register:l=!0,dest:m="public",sw:u="sw.js",cacheStartUrl:c=!0,dynamicStartUrl:_=!0,dynamicStartUrlRedirect:d,publicExcludes:f=["!noprecache/**/*"],fallbacks:b={},cacheOnFrontEndNav:j=!1,aggressiveFrontEndNavCaching:g=!1,reloadOnOnline:h=!0,scope:w=r.basePath,customWorkerSrc:x="worker",customWorkerDest:A=m,customWorkerPrefix:P="worker",workboxOptions:{additionalManifestEntries:k,manifestTransforms:y=[],exclude:v=[/\/_next\/static\/.*(?<!\.p)\.woff2/,/\.map$/,/^manifest.*\.js$/],...E}={},extendDefaultRuntimeCaching:W=!1})=>{if(p)return {disable:p};let $=e$1.resolve(t.dir,"public");k||(k=s$1.sync(["**/*","!workbox-*.js","!workbox-*.js.map","!worker-*.js","!worker-*.js.map","!fallback-*.js","!fallback-*.js.map","!swe-worker-*.js","!swe-worker-*.js.map",`!${u.replace(/^\/+/,"")}`,`!${u.replace(/^\/+/,"")}.map`,...f],{cwd:$}).map(t=>({url:e$1.posix.join(r.basePath,t),revision:getFileHash(e$1.resolve($,t))}))),c&&(_?"string"==typeof d&&d.length>0&&k.push({url:d,revision:t.buildId}):k.push({url:r.basePath,revision:t.buildId}));let O=e$1.join(t.dir,m);return e$1.isAbsolute(x)||(x=e$1.join(t.dir,x)),b&&!b.document&&(b.document=getDefaultDocumentPage(t.dir,r.pageExtensions)),{disable:p,register:l,dest:O,sw:e$1.posix.join(r.basePath,u),cacheStartUrl:c,dynamicStartUrl:_,dynamicStartUrlRedirect:d,publicExcludes:f,fallbacks:b,cacheOnFrontEndNav:j,aggressiveFrontEndNavCaching:g,reloadOnOnline:h,scope:e$1.posix.join(w,"/"),customWorkerSrc:x,customWorkerDest:e$1.resolve(t.dir,A),customWorkerPrefix:P,workboxOptions:{...E,swDest:e$1.join(O,u),additionalManifestEntries:t.dev?[]:k,exclude:[...v,({asset:e})=>!!(e.name.startsWith("server/")||e.name.match(/^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/))||!!t.dev&&!e.name.startsWith("static/runtime/")],manifestTransforms:[...y,async(s,n)=>{let o=relativeToOutputPath$1(n,$),p=`${i}${o}`;return {manifest:s.map(s=>{if(s.url=s.url.replace("/_next//static/image","/_next/static/image").replace("/_next//static/media","/_next/static/media"),s.url.startsWith(p)&&(s.url=e$1.posix.join(r.basePath,s.url.replace(p,""))),null===s.revision){let e=s.url;"string"==typeof i&&e.startsWith(i)&&(e=s.url.substring(i.length));let r=n.assetsInfo.get(e);s.revision=r&&r.contenthash||t.buildId;}return s.url=s.url.replace(/\[/g,"%5B").replace(/\]/g,"%5D"),s}),warnings:[]}}]},extendDefaultRuntimeCaching:W}};const createContext=(t,s,a,n,o)=>{"function"==typeof a.webpack&&(n=a.webpack(n,s));let l={...s.config,basePath:s.config.basePath||"/"},m=n.output?.publicPath,u=parseOptions(s,m,l,o);if(n.plugins||(n.plugins=[]),u.disable)return s.isServer||info("PWA support is disabled."),{disabled:!0,webpackConfig:n};let c=loadTSConfig(s.dir,l.typescript.tsconfigPath);n.plugins.push(new t.DefinePlugin({__PWA_SW__:`'${u.sw}'`,__PWA_SCOPE__:`'${u.scope}'`,__PWA_ENABLE_REGISTER__:`${!!u.register}`,__PWA_START_URL__:u.dynamicStartUrl?`'${l.basePath}'`:void 0,__PWA_CACHE_ON_FRONT_END_NAV__:`${!!u.cacheOnFrontEndNav}`,__PWA_AGGRFEN_CACHE__:`${!!u.aggressiveFrontEndNavCaching}`,__PWA_RELOAD_ON_ONLINE__:`${!!u.reloadOnOnline}`}));let _=e$1.join(p,"sw-entry.js"),d=n.entry;return n.entry=async()=>{let e=await d();return e["main.js"]&&!e["main.js"].includes(_)&&(Array.isArray(e["main.js"])?e["main.js"].unshift(_):"string"==typeof e["main.js"]&&(e["main.js"]=[_,e["main.js"]])),e["main-app"]&&!e["main-app"].includes(_)&&(Array.isArray(e["main-app"])?e["main-app"].unshift(_):"string"==typeof e["main-app"]&&(e["main-app"]=[_,e["main-app"]])),e},{disabled:!1,publicPath:m,nextConfig:l,webpack:t,webpackContext:s,webpackConfig:n,tsConfig:c,userOptions:o,options:u}}; | ||
const resolveRuntimeCaching=(o,n)=>{if(!o)return t;if(!n)return info("Custom runtimeCaching array found, using it instead of the default one."),o;info("Custom runtimeCaching array found, using it to extend the default one.");let i=[],a=new Set;for(let e of o)i.push(e),e.options?.cacheName&&a.add(e.options.cacheName);for(let e of t)e.options?.cacheName&&a.has(e.options.cacheName)||i.push(e);return i};const relativeToOutputPath=(o,e)=>e$1.isAbsolute(e)?e$1.relative(o.options.output.path,e):e;class ChildCompilationPlugin{src;dest;plugins;webpack;constructor({src:t,dest:i,plugins:s,webpack:e}){this.src=t,this.dest=i,this.plugins=s,this.webpack=e;}apply(t){t.hooks.make.tapPromise(this.constructor.name,i=>this.performChildCompilation(i,t).catch(t=>{i.errors.push(t);}));}async performChildCompilation(i,s){let e=relativeToOutputPath(i,this.dest),r=i.createChildCompiler(this.constructor.name,{filename:e},[]);if(r.context=s.context,r.inputFileSystem=s.inputFileSystem,r.outputFileSystem=s.outputFileSystem,void 0!==this.plugins)for(let t of this.plugins)t?.apply(r);new this.webpack.EntryPlugin(s.context,this.src,this.constructor.name).apply(r),await new Promise((t,s)=>{r.runAsChild((e,r,o)=>{e?s(e):(i.warnings=i.warnings.concat(o?.warnings??[]),i.errors=i.errors.concat(o?.errors??[]),t());});});}}const buildCustomWorker=s=>{let i=s$1.sync("{src/,}index.{ts,js}",{cwd:s.options.customWorkerSrc});if(0===i.length)return;let m=e$1.join(s.options.customWorkerSrc,i[0]);event(`Found a custom worker implementation at ${m}.`);let p=`${s.options.customWorkerPrefix}-${getContentHash(m,s.webpackContext.dev)}.js`;return event(`Building the custom worker to ${e$1.join(s.options.customWorkerDest,p)}...`),{name:e$1.posix.join(s.nextConfig.basePath,p),pluginInstance:new ChildCompilationPlugin({src:m,dest:e$1.join(s.options.customWorkerDest,p),webpack:s.webpack})}};const getFallbackEnvs=({fallbacks:L,buildId:e})=>{let t=L.data;t?.endsWith(".json")&&(t=e$1.posix.join("/_next/data",e,t));let o={__PWA_FALLBACK_DOCUMENT__:L.document||!1,__PWA_FALLBACK_IMAGE__:L.image||!1,__PWA_FALLBACK_AUDIO__:L.audio||!1,__PWA_FALLBACK_VIDEO__:L.video||!1,__PWA_FALLBACK_FONT__:L.font||!1,__PWA_FALLBACK_DATA__:t||!1};if(0!==Object.values(o).filter(_=>!!_).length)return info("This app will fallback to these precached routes when fetching from the cache and the network fails:"),o.__PWA_FALLBACK_DOCUMENT__&&info(` Documents (pages): ${o.__PWA_FALLBACK_DOCUMENT__}`),o.__PWA_FALLBACK_IMAGE__&&info(` Images: ${o.__PWA_FALLBACK_IMAGE__}`),o.__PWA_FALLBACK_AUDIO__&&info(` Audio: ${o.__PWA_FALLBACK_AUDIO__}`),o.__PWA_FALLBACK_VIDEO__&&info(` Videos: ${o.__PWA_FALLBACK_VIDEO__}`),o.__PWA_FALLBACK_FONT__&&info(` Fonts: ${o.__PWA_FALLBACK_FONT__}`),o.__PWA_FALLBACK_DATA__&&info(` Data (/_next/data/**/*.json): ${o.__PWA_FALLBACK_DATA__}`),o};let i=fileURLToPath(new URL(".",import.meta.url));const buildFallbackWorker=t=>{let a=getFallbackEnvs({fallbacks:Object.keys(t.options.fallbacks).reduce((n,o)=>{let l=t.options.fallbacks[o];return l&&(n[o]=e$1.posix.join(t.nextConfig.basePath,l)),n},{}),buildId:t.webpackContext.buildId});if(!a)return;let s=e$1.join(i,"fallback.js"),r=`fallback-${getContentHash(s,t.webpackContext.dev)}.js`;return {name:e$1.posix.join(t.nextConfig.basePath,r),precaches:Object.values(a).filter(e=>!!e),pluginInstance:new ChildCompilationPlugin({src:s,dest:e$1.join(t.options.dest,r),plugins:[new t.webpack.EnvironmentPlugin(a)],webpack:t.webpack})}};const buildWorkers=i=>{let s=[],n=buildCustomWorker(i);i.options.workboxOptions.importScripts||(i.options.workboxOptions.importScripts=[]),void 0!==n&&(i.options.workboxOptions.importScripts.unshift(n.name),s.push(n.pluginInstance));let r=!1;if(i.options.fallbacks){let o=buildFallbackWorker(i);if(o)for(let t of(r=!0,i.options.workboxOptions.importScripts.unshift(o.name),s.push(o.pluginInstance),i.options.workboxOptions.additionalManifestEntries||(i.options.workboxOptions.additionalManifestEntries=[]),o.precaches))t&&"boolean"!=typeof t&&!i.options.workboxOptions.additionalManifestEntries.find(o=>"object"==typeof o&&o.url.startsWith(t))&&i.options.workboxOptions.additionalManifestEntries.push({url:t,revision:i.webpackContext.buildId});}return {hasFallbacks:r,childCompilationInstances:s}};const resolveWorkboxPlugin=a=>{let p;if(isInjectManifestConfig(a.options.workboxOptions)){let n=e$1.join(a.webpackContext.dir,a.options.workboxOptions.swSrc);event(`Using InjectManifest with ${n}`);let i=new o$2.InjectManifest({...a.options.workboxOptions,swSrc:n});return a.webpackContext.dev&&overrideAfterCalledMethod(i),[i]}let{hasFallbacks:l,childCompilationInstances:c}=buildWorkers(a),{skipWaiting:d=!0,clientsClaim:u=!0,cleanupOutdatedCaches:h=!0,ignoreURLParametersMatching:f=[/^utm_/,/^fbclid$/],importScripts:m,runtimeCaching:b,...w}=a.options.workboxOptions,k=!1;a.webpackContext.dev?(info("Building in development mode, caching and precaching are disabled for the most part. This means that offline support is disabled, but you can continue developing other functions in service worker."),f.push(/ts/),p=[{urlPattern:/.*/i,handler:"NetworkOnly",options:{cacheName:"dev"}}],k=!0):p=resolveRuntimeCaching(b,a.options.extendDefaultRuntimeCaching),a.options.dynamicStartUrl&&p.unshift({urlPattern:a.nextConfig.basePath,handler:"NetworkFirst",options:{cacheName:"start-url",plugins:[{cacheWillUpdate:async({response:e})=>e&&"opaqueredirect"===e.type?new Response(e.body,{status:200,statusText:"OK",headers:e.headers}):e}]}}),l&&p.forEach(e=>{!e.options||e.options.precacheFallback||e.options.plugins?.find(e=>"handlerDidError"in e)||(e.options.plugins||(e.options.plugins=[]),e.options.plugins.push({handlerDidError:async({request:e})=>"undefined"!=typeof self?self.fallback(e):Response.error()}));});let g=new o$2.GenerateSW({...w,skipWaiting:d,clientsClaim:u,cleanupOutdatedCaches:h,ignoreURLParametersMatching:f,importScripts:m,runtimeCaching:p});return k&&overrideAfterCalledMethod(g),[g,...c]};let r=fileURLToPath(new URL(".",import.meta.url));const buildSWEntryWorker=e=>{if(!e.options.cacheOnFrontEndNav)return;let i=e$1.join(r,"sw-entry-worker.js"),s=`swe-worker-${getContentHash(i,e.webpackContext.dev)}.js`;return {name:e$1.posix.join(e.nextConfig.basePath,s),pluginInstance:new ChildCompilationPlugin({src:i,dest:e$1.join(e.options.dest,s),webpack:e.webpack})}};var index = ((n={})=>(p={})=>({...p,webpack(a,c){let w=createContext(c.webpack,c,p,a,n);if(w.disabled)return w.webpackConfig;if(w.webpackConfig.plugins||(w.webpackConfig.plugins=[]),event(`Compiling for ${c.isServer?"server":"client (static)"}...`),!c.isServer){let n=buildSWEntryWorker(w);w.webpackConfig.plugins.push(new w.webpack.DefinePlugin({__PWA_SW_ENTRY_WORKER__:n?.name&&`'${n.name}'`}),...n?[n.pluginInstance]:[]),w.options.register||(info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:"),info(" window.workbox.register()"),w.tsConfig?.compilerOptions?.types?.includes("@ducanh2912/next-pwa/workbox")||info("You may also want to add @ducanh2912/next-pwa/workbox to compilerOptions.types in your tsconfig.json/jsconfig.json.")),info(`Service worker: ${e$1.join(w.options.dest,w.options.sw)}`),info(` URL: ${w.options.sw}`),info(` Scope: ${w.options.scope}`),w.webpackConfig.plugins.push(new CleanWebpackPlugin({cleanOnceBeforeBuildPatterns:[e$1.join(w.options.dest,"{workbox,fallback,swe-worker,worker}-*.js"),e$1.join(w.options.dest,"{workbox,fallback,swe-worker,worker}-*.js.map"),e$1.join(w.options.dest,w.options.sw),e$1.join(w.options.dest,`${w.options.sw}.map`),e$1.join(w.options.customWorkerDest,`${w.options.customWorkerPrefix}-*.js`),e$1.join(w.options.customWorkerDest,`${w.options.customWorkerPrefix}-*.js.map`)]})),w.webpackConfig.plugins.push(...resolveWorkboxPlugin(w));}return w.webpackConfig}}));export{index as default,t as runtimeCaching}; | ||
import e$1 from'path';import {CleanWebpackPlugin}from'clean-webpack-plugin';import {createRequire}from'module';import e$2 from'fs';import t$3 from'process';import e$3 from'os';import o$1 from'tty';import {coerce,lt}from'semver';import {fileURLToPath}from'url';import s$1 from'fast-glob';import e$4 from'crypto';import o$2 from'workbox-webpack-plugin';const findFirstTruthy = (t, r)=>{ | ||
for (let e of t){ | ||
let t = r(e); | ||
if (t) return t; | ||
} | ||
};let r$4 = createRequire(import.meta.url); | ||
const getPackageVersion = (e)=>{ | ||
try { | ||
return r$4(`${e}/package.json`).version; | ||
} catch { | ||
return; | ||
} | ||
};const loadTSConfig = (n, e)=>{ | ||
try { | ||
let i = findFirstTruthy([ | ||
e ?? "tsconfig.json", | ||
"jsconfig.json" | ||
], (o)=>{ | ||
let e = e$1.join(n, o); | ||
return e$2.existsSync(e) ? e : void 0; | ||
}); | ||
if (!i) return; | ||
return JSON.parse(e$2.readFileSync(i, "utf-8")); | ||
} catch { | ||
return; | ||
} | ||
};let e = (e = 0)=>(r)=>`\u001B[${r + e}m`, r$3 = (e = 0)=>(r)=>`\u001B[${38 + e};5;${r}m`, o = (e = 0)=>(r, o, t)=>`\u001B[${38 + e};2;${r};${o};${t}m`, t$2 = { | ||
modifier: { | ||
reset: [ | ||
0, | ||
0 | ||
], | ||
bold: [ | ||
1, | ||
22 | ||
], | ||
dim: [ | ||
2, | ||
22 | ||
], | ||
italic: [ | ||
3, | ||
23 | ||
], | ||
underline: [ | ||
4, | ||
24 | ||
], | ||
overline: [ | ||
53, | ||
55 | ||
], | ||
inverse: [ | ||
7, | ||
27 | ||
], | ||
hidden: [ | ||
8, | ||
28 | ||
], | ||
strikethrough: [ | ||
9, | ||
29 | ||
] | ||
}, | ||
color: { | ||
black: [ | ||
30, | ||
39 | ||
], | ||
red: [ | ||
31, | ||
39 | ||
], | ||
green: [ | ||
32, | ||
39 | ||
], | ||
yellow: [ | ||
33, | ||
39 | ||
], | ||
blue: [ | ||
34, | ||
39 | ||
], | ||
magenta: [ | ||
35, | ||
39 | ||
], | ||
cyan: [ | ||
36, | ||
39 | ||
], | ||
white: [ | ||
37, | ||
39 | ||
], | ||
blackBright: [ | ||
90, | ||
39 | ||
], | ||
gray: [ | ||
90, | ||
39 | ||
], | ||
grey: [ | ||
90, | ||
39 | ||
], | ||
redBright: [ | ||
91, | ||
39 | ||
], | ||
greenBright: [ | ||
92, | ||
39 | ||
], | ||
yellowBright: [ | ||
93, | ||
39 | ||
], | ||
blueBright: [ | ||
94, | ||
39 | ||
], | ||
magentaBright: [ | ||
95, | ||
39 | ||
], | ||
cyanBright: [ | ||
96, | ||
39 | ||
], | ||
whiteBright: [ | ||
97, | ||
39 | ||
] | ||
}, | ||
bgColor: { | ||
bgBlack: [ | ||
40, | ||
49 | ||
], | ||
bgRed: [ | ||
41, | ||
49 | ||
], | ||
bgGreen: [ | ||
42, | ||
49 | ||
], | ||
bgYellow: [ | ||
43, | ||
49 | ||
], | ||
bgBlue: [ | ||
44, | ||
49 | ||
], | ||
bgMagenta: [ | ||
45, | ||
49 | ||
], | ||
bgCyan: [ | ||
46, | ||
49 | ||
], | ||
bgWhite: [ | ||
47, | ||
49 | ||
], | ||
bgBlackBright: [ | ||
100, | ||
49 | ||
], | ||
bgGray: [ | ||
100, | ||
49 | ||
], | ||
bgGrey: [ | ||
100, | ||
49 | ||
], | ||
bgRedBright: [ | ||
101, | ||
49 | ||
], | ||
bgGreenBright: [ | ||
102, | ||
49 | ||
], | ||
bgYellowBright: [ | ||
103, | ||
49 | ||
], | ||
bgBlueBright: [ | ||
104, | ||
49 | ||
], | ||
bgMagentaBright: [ | ||
105, | ||
49 | ||
], | ||
bgCyanBright: [ | ||
106, | ||
49 | ||
], | ||
bgWhiteBright: [ | ||
107, | ||
49 | ||
] | ||
} | ||
}; | ||
Object.keys(t$2.modifier); | ||
const foregroundColorNames = Object.keys(t$2.color); | ||
const backgroundColorNames = Object.keys(t$2.bgColor); | ||
[ | ||
...foregroundColorNames, | ||
...backgroundColorNames | ||
]; | ||
let n$2 = function() { | ||
let n = new Map(); | ||
for (let [e, r] of Object.entries(t$2)){ | ||
for (let [e, o] of Object.entries(r))t$2[e] = { | ||
open: `\u001B[${o[0]}m`, | ||
close: `\u001B[${o[1]}m` | ||
}, r[e] = t$2[e], n.set(o[0], o[1]); | ||
Object.defineProperty(t$2, e, { | ||
value: r, | ||
enumerable: !1 | ||
}); | ||
} | ||
return Object.defineProperty(t$2, 'codes', { | ||
value: n, | ||
enumerable: !1 | ||
}), t$2.color.close = '\u001B[39m', t$2.bgColor.close = '\u001B[49m', t$2.color.ansi = e(), t$2.color.ansi256 = r$3(), t$2.color.ansi16m = o(), t$2.bgColor.ansi = e(10), t$2.bgColor.ansi256 = r$3(10), t$2.bgColor.ansi16m = o(10), Object.defineProperties(t$2, { | ||
rgbToAnsi256: { | ||
value: (e, r, o)=>e === r && r === o ? e < 8 ? 16 : e > 248 ? 231 : Math.round((e - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(e / 255 * 5) + 6 * Math.round(r / 255 * 5) + Math.round(o / 255 * 5), | ||
enumerable: !1 | ||
}, | ||
hexToRgb: { | ||
value (e) { | ||
let r = /[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16)); | ||
if (!r) return [ | ||
0, | ||
0, | ||
0 | ||
]; | ||
let [o] = r; | ||
3 === o.length && (o = [ | ||
...o | ||
].map((e)=>e + e).join('')); | ||
let t = Number.parseInt(o, 16); | ||
return [ | ||
t >> 16 & 0xFF, | ||
t >> 8 & 0xFF, | ||
0xFF & t | ||
]; | ||
}, | ||
enumerable: !1 | ||
}, | ||
hexToAnsi256: { | ||
value: (e)=>t$2.rgbToAnsi256(...t$2.hexToRgb(e)), | ||
enumerable: !1 | ||
}, | ||
ansi256ToAnsi: { | ||
value (e) { | ||
let r, o, t; | ||
if (e < 8) return 30 + e; | ||
if (e < 16) return 90 + (e - 8); | ||
if (e >= 232) o = r = ((e - 232) * 10 + 8) / 255, t = r; | ||
else { | ||
let n = (e -= 16) % 36; | ||
r = Math.floor(e / 36) / 5, o = Math.floor(n / 6) / 5, t = n % 6 / 5; | ||
} | ||
let n = 2 * Math.max(r, o, t); | ||
if (0 === n) return 30; | ||
let l = 30 + (Math.round(t) << 2 | Math.round(o) << 1 | Math.round(r)); | ||
return 2 === n && (l += 60), l; | ||
}, | ||
enumerable: !1 | ||
}, | ||
rgbToAnsi: { | ||
value: (e, r, o)=>t$2.ansi256ToAnsi(t$2.rgbToAnsi256(e, r, o)), | ||
enumerable: !1 | ||
}, | ||
hexToAnsi: { | ||
value: (e)=>t$2.ansi256ToAnsi(t$2.hexToAnsi256(e)), | ||
enumerable: !1 | ||
} | ||
}), t$2; | ||
}();let r$2; | ||
function i$3(r, e = globalThis.Deno ? globalThis.Deno.args : t$3.argv) { | ||
let o = r.startsWith('-') ? '' : 1 === r.length ? '-' : '--', i = e.indexOf(o + r), n = e.indexOf('--'); | ||
return -1 !== i && (-1 === n || i < n); | ||
} | ||
let { env: n$1 } = t$3; | ||
i$3('no-color') || i$3('no-colors') || i$3('color=false') || i$3('color=never') ? r$2 = 0 : (i$3('color') || i$3('colors') || i$3('color=true') || i$3('color=always')) && (r$2 = 1); | ||
function createSupportsColor(o, l = {}) { | ||
var s; | ||
return 0 !== (s = function(o, { streamIsTTY: l, sniffFlags: s = !0 } = {}) { | ||
let u = function() { | ||
if ('FORCE_COLOR' in n$1) return 'true' === n$1.FORCE_COLOR ? 1 : 'false' === n$1.FORCE_COLOR ? 0 : 0 === n$1.FORCE_COLOR.length ? 1 : Math.min(Number.parseInt(n$1.FORCE_COLOR, 10), 3); | ||
}(); | ||
void 0 !== u && (r$2 = u); | ||
let R = s ? r$2 : u; | ||
if (0 === R) return 0; | ||
if (s) { | ||
if (i$3('color=16m') || i$3('color=full') || i$3('color=truecolor')) return 3; | ||
if (i$3('color=256')) return 2; | ||
} | ||
if ('TF_BUILD' in n$1 && 'AGENT_NAME' in n$1) return 1; | ||
if (o && !l && void 0 === R) return 0; | ||
let T = R || 0; | ||
if ('dumb' === n$1.TERM) return T; | ||
if ('win32' === t$3.platform) { | ||
let r = e$3.release().split('.'); | ||
return Number(r[0]) >= 10 && Number(r[2]) >= 10_586 ? Number(r[2]) >= 14_931 ? 3 : 2 : 1; | ||
} | ||
if ('CI' in n$1) return 'GITHUB_ACTIONS' in n$1 || 'GITEA_ACTIONS' in n$1 ? 3 : [ | ||
'TRAVIS', | ||
'CIRCLECI', | ||
'APPVEYOR', | ||
'GITLAB_CI', | ||
'BUILDKITE', | ||
'DRONE' | ||
].some((r)=>r in n$1) || 'codeship' === n$1.CI_NAME ? 1 : T; | ||
if ('TEAMCITY_VERSION' in n$1) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n$1.TEAMCITY_VERSION) ? 1 : 0; | ||
if ('truecolor' === n$1.COLORTERM || 'xterm-kitty' === n$1.TERM) return 3; | ||
if ('TERM_PROGRAM' in n$1) { | ||
let r = Number.parseInt((n$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10); | ||
switch(n$1.TERM_PROGRAM){ | ||
case 'iTerm.app': | ||
return r >= 3 ? 3 : 2; | ||
case 'Apple_Terminal': | ||
return 2; | ||
} | ||
} | ||
return /-256(color)?$/i.test(n$1.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n$1.TERM) || 'COLORTERM' in n$1 ? 1 : T; | ||
}(o, { | ||
streamIsTTY: o && o.isTTY, | ||
...l | ||
})) && { | ||
level: s, | ||
hasBasic: !0, | ||
has256: s >= 2, | ||
has16m: s >= 3 | ||
}; | ||
} | ||
let l$2 = { | ||
stdout: createSupportsColor({ | ||
isTTY: o$1.isatty(1) | ||
}), | ||
stderr: createSupportsColor({ | ||
isTTY: o$1.isatty(2) | ||
}) | ||
};function stringReplaceAll(e, n, i) { | ||
let t = e.indexOf(n); | ||
if (-1 === t) return e; | ||
let l = n.length, r = 0, c = ''; | ||
do c += e.slice(r, t) + n + i, r = t + l, t = e.indexOf(n, r); | ||
while (-1 !== t) | ||
return c + e.slice(r); | ||
} | ||
function stringEncaseCRLFWithFirstIndex(e, n, i, t) { | ||
let l = 0, r = ''; | ||
do { | ||
let c = '\r' === e[t - 1]; | ||
r += e.slice(l, c ? t - 1 : t) + n + (c ? '\r\n' : '\n') + i, l = t + 1, t = e.indexOf('\n', l); | ||
}while (-1 !== t) | ||
return r + e.slice(l); | ||
}let { stdout: l$1, stderr: s } = l$2, i$2 = Symbol('GENERATOR'), n = Symbol('STYLER'), a$1 = Symbol('IS_EMPTY'), u = [ | ||
'ansi', | ||
'ansi', | ||
'ansi256', | ||
'ansi16m' | ||
], p$2 = Object.create(null), c = (e, t = {})=>{ | ||
if (t.level && !(Number.isInteger(t.level) && t.level >= 0 && t.level <= 3)) throw Error('The `level` option should be an integer from 0 to 3'); | ||
let o = l$1 ? l$1.level : 0; | ||
e.level = void 0 === t.level ? o : t.level; | ||
}; | ||
let f = (e)=>{ | ||
let t = (...e)=>e.join(' '); | ||
return c(t, e), Object.setPrototypeOf(t, b.prototype), t; | ||
}; | ||
function b(e) { | ||
return f(e); | ||
} | ||
for (let [t, o] of (Object.setPrototypeOf(b.prototype, Function.prototype), Object.entries(n$2)))p$2[t] = { | ||
get () { | ||
let e = v(this, h(o.open, o.close, this[n]), this[a$1]); | ||
return Object.defineProperty(this, t, { | ||
value: e | ||
}), e; | ||
} | ||
}; | ||
p$2.visible = { | ||
get () { | ||
let e = v(this, this[n], !0); | ||
return Object.defineProperty(this, 'visible', { | ||
value: e | ||
}), e; | ||
} | ||
}; | ||
let d = (t, o, r, ...l)=>'rgb' === t ? 'ansi16m' === o ? n$2[r].ansi16m(...l) : 'ansi256' === o ? n$2[r].ansi256(n$2.rgbToAnsi256(...l)) : n$2[r].ansi(n$2.rgbToAnsi(...l)) : 'hex' === t ? d('rgb', o, r, ...n$2.hexToRgb(...l)) : n$2[r][t](...l); | ||
for (let t of [ | ||
'rgb', | ||
'hex', | ||
'ansi256' | ||
])p$2[t] = { | ||
get () { | ||
let { level: o } = this; | ||
return function(...r) { | ||
return v(this, h(d(t, u[o], 'color', ...r), n$2.color.close, this[n]), this[a$1]); | ||
}; | ||
} | ||
}, p$2['bg' + t[0].toUpperCase() + t.slice(1)] = { | ||
get () { | ||
let { level: o } = this; | ||
return function(...r) { | ||
return v(this, h(d(t, u[o], 'bgColor', ...r), n$2.bgColor.close, this[n]), this[a$1]); | ||
}; | ||
} | ||
}; | ||
let m = Object.defineProperties(()=>{}, { | ||
...p$2, | ||
level: { | ||
enumerable: !0, | ||
get () { | ||
return this[i$2].level; | ||
}, | ||
set (e) { | ||
this[i$2].level = e; | ||
} | ||
} | ||
}), h = (e, t, o)=>{ | ||
let r, l; | ||
return void 0 === o ? (r = e, l = t) : (r = o.openAll + e, l = t + o.closeAll), { | ||
open: e, | ||
close: t, | ||
openAll: r, | ||
closeAll: l, | ||
parent: o | ||
}; | ||
}, v = (e, t, o)=>{ | ||
let r = (...e)=>g(r, 1 === e.length ? '' + e[0] : e.join(' ')); | ||
return Object.setPrototypeOf(r, m), r[i$2] = e, r[n] = t, r[a$1] = o, r; | ||
}, g = (e, t)=>{ | ||
if (e.level <= 0 || !t) return e[a$1] ? '' : t; | ||
let l = e[n]; | ||
if (void 0 === l) return t; | ||
let { openAll: s, closeAll: i } = l; | ||
if (t.includes('\u001B')) for(; void 0 !== l;)t = stringReplaceAll(t, l.close, l.open), l = l.parent; | ||
let u = t.indexOf('\n'); | ||
return -1 !== u && (t = stringEncaseCRLFWithFirstIndex(t, i, s, u)), s + t + i; | ||
}; | ||
Object.defineProperties(b.prototype, p$2); | ||
let y = f(void 0); | ||
f({ | ||
level: s ? s.level : 0 | ||
}); | ||
var r$1 = y;let a = coerce(getPackageVersion("next")), t$1 = !!a && lt(a, "13.4.1"), w = !!a && lt(a, "13.4.20"), i$1 = { | ||
wait: "log", | ||
error: "error", | ||
warn: "warn", | ||
info: "log", | ||
event: "log" | ||
}, l = t$1 ? { | ||
wait: `${r$1.cyan("wait")} - (PWA)`, | ||
error: `${r$1.red("error")} - (PWA)`, | ||
warn: `${r$1.yellow("warn")} - (PWA)`, | ||
info: `${r$1.cyan("info")} - (PWA)`, | ||
event: `${r$1.cyan("info")} - (PWA)` | ||
} : w ? { | ||
wait: `- ${r$1.cyan("wait")} (pwa)`, | ||
error: `- ${r$1.red("error")} (pwa)`, | ||
warn: `- ${r$1.yellow("warn")} (pwa)`, | ||
info: `- ${r$1.cyan("info")} (pwa)`, | ||
event: `- ${r$1.cyan("info")} (pwa)` | ||
} : { | ||
wait: `${r$1.white(r$1.bold("\u25CB"))} (pwa)`, | ||
error: `${r$1.red(r$1.bold("X"))} (pwa)`, | ||
warn: `${r$1.yellow(r$1.bold("\u26A0"))} (pwa)`, | ||
info: `${r$1.white(r$1.bold("\u25CB"))} (pwa)`, | ||
event: `${r$1.green(r$1.bold("\u2713"))} (pwa)` | ||
}, p$1 = (r, ...o)=>{ | ||
let e = i$1[r], n = l[r]; | ||
if (w) return console[e](n, ...o); | ||
("" === o[0] || void 0 === o[0]) && 1 === o.length && o.shift(), 0 === o.length ? console[e]("") : console[e](` ${n}`, ...o); | ||
}; | ||
const info = (...r)=>{ | ||
p$1("info", ...r); | ||
}; | ||
const event = (...r)=>{ | ||
p$1("event", ...r); | ||
};const normalizePathSep = (e)=>e.replace(/\\/g, "/");function relativeToOutputPath$1(e, r) { | ||
return e$1.resolve(r) === e$1.normalize(r) ? normalizePathSep(e$1.relative(e.options.output.path, r)) : normalizePathSep(r); | ||
}var t = [ | ||
{ | ||
urlPattern: /^https:\/\/fonts\.(?:gstatic)\.com\/.*/i, | ||
handler: "CacheFirst", | ||
options: { | ||
cacheName: "google-fonts-webfonts", | ||
expiration: { | ||
maxEntries: 4, | ||
maxAgeSeconds: 31536000 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /^https:\/\/fonts\.(?:googleapis)\.com\/.*/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "google-fonts-stylesheets", | ||
expiration: { | ||
maxEntries: 4, | ||
maxAgeSeconds: 604800 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "static-font-assets", | ||
expiration: { | ||
maxEntries: 4, | ||
maxAgeSeconds: 604800 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "static-image-assets", | ||
expiration: { | ||
maxEntries: 64, | ||
maxAgeSeconds: 2592000 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\/_next\/static.+\.js$/i, | ||
handler: "CacheFirst", | ||
options: { | ||
cacheName: "next-static-js-assets", | ||
expiration: { | ||
maxEntries: 64, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\/_next\/image\?url=.+$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "next-image", | ||
expiration: { | ||
maxEntries: 64, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:mp3|wav|ogg)$/i, | ||
handler: "CacheFirst", | ||
options: { | ||
rangeRequests: !0, | ||
cacheName: "static-audio-assets", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:mp4|webm)$/i, | ||
handler: "CacheFirst", | ||
options: { | ||
rangeRequests: !0, | ||
cacheName: "static-video-assets", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:js)$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "static-js-assets", | ||
expiration: { | ||
maxEntries: 48, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:css|less)$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "static-style-assets", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\/_next\/data\/.+\/.+\.json$/i, | ||
handler: "StaleWhileRevalidate", | ||
options: { | ||
cacheName: "next-data", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: /\.(?:json|xml|csv)$/i, | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "static-data-assets", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: ({ sameOrigin: e, url: { pathname: t } })=>!(!e || t.startsWith("/api/auth/callback")) && !!t.startsWith("/api/"), | ||
handler: "NetworkFirst", | ||
method: "GET", | ||
options: { | ||
cacheName: "apis", | ||
expiration: { | ||
maxEntries: 16, | ||
maxAgeSeconds: 86400 | ||
}, | ||
networkTimeoutSeconds: 10 | ||
} | ||
}, | ||
{ | ||
urlPattern: ({ request: e, url: { pathname: t }, sameOrigin: a })=>"1" === e.headers.get("RSC") && "1" === e.headers.get("Next-Router-Prefetch") && a && !t.startsWith("/api/"), | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "pages-rsc-prefetch", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: ({ request: e, url: { pathname: t }, sameOrigin: a })=>"1" === e.headers.get("RSC") && a && !t.startsWith("/api/"), | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "pages-rsc", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: ({ url: { pathname: e }, sameOrigin: t })=>t && !e.startsWith("/api/"), | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "pages", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 86400 | ||
} | ||
} | ||
}, | ||
{ | ||
urlPattern: ({ sameOrigin: e })=>!e, | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "cross-origin", | ||
expiration: { | ||
maxEntries: 32, | ||
maxAgeSeconds: 3600 | ||
}, | ||
networkTimeoutSeconds: 10 | ||
} | ||
} | ||
];const overrideAfterCalledMethod = (e)=>{ | ||
Object.defineProperty(e, "alreadyCalled", { | ||
get: ()=>!1, | ||
set () {} | ||
}); | ||
}; | ||
const isInjectManifestConfig = (e)=>void 0 !== e && "string" == typeof e.swSrc; | ||
const getFileHash = (r)=>e$4.createHash("md5").update(e$2.readFileSync(r)).digest("hex"); | ||
const getContentHash = (e, t)=>t ? "development" : getFileHash(e).slice(0, 16);const getDefaultDocumentPage = (f, t)=>{ | ||
let n = findFirstTruthy([ | ||
"pages", | ||
"src/pages" | ||
], (o)=>(o = e$1.join(f, o), e$2.existsSync(o) ? o : void 0)), s = findFirstTruthy([ | ||
"app", | ||
"src/app" | ||
], (o)=>(o = e$1.join(f, o), e$2.existsSync(o) ? o : void 0)); | ||
if (n || s) for (let o of t){ | ||
if (s) { | ||
let f = e$1.join(s, `~offline/page.${o}`); | ||
if (e$2.existsSync(f)) return "/~offline"; | ||
} | ||
if (n) { | ||
let f = e$1.join(n, `_offline.${o}`); | ||
if (f && e$2.existsSync(f)) return "/_offline"; | ||
} | ||
} | ||
};let p = fileURLToPath(new URL(".", import.meta.url)); | ||
const parseOptions = (t, i, r, { disable: p = !1, register: l = !0, dest: m = "public", sw: u = "sw.js", cacheStartUrl: c = !0, dynamicStartUrl: _ = !0, dynamicStartUrlRedirect: d, publicExcludes: f = [ | ||
"!noprecache/**/*" | ||
], fallbacks: b = {}, cacheOnFrontEndNav: j = !1, aggressiveFrontEndNavCaching: g = !1, reloadOnOnline: h = !0, scope: w = r.basePath, customWorkerSrc: x = "worker", customWorkerDest: A = m, customWorkerPrefix: P = "worker", workboxOptions: { additionalManifestEntries: k, manifestTransforms: y = [], exclude: v = [ | ||
/\/_next\/static\/.*(?<!\.p)\.woff2/, | ||
/\.map$/, | ||
/^manifest.*\.js$/ | ||
], ...E } = {}, extendDefaultRuntimeCaching: W = !1 })=>{ | ||
if (p) return { | ||
disable: p | ||
}; | ||
let $ = e$1.resolve(t.dir, "public"); | ||
k || (k = s$1.sync([ | ||
"**/*", | ||
"!workbox-*.js", | ||
"!workbox-*.js.map", | ||
"!worker-*.js", | ||
"!worker-*.js.map", | ||
"!fallback-*.js", | ||
"!fallback-*.js.map", | ||
"!swe-worker-*.js", | ||
"!swe-worker-*.js.map", | ||
`!${u.replace(/^\/+/, "")}`, | ||
`!${u.replace(/^\/+/, "")}.map`, | ||
...f | ||
], { | ||
cwd: $ | ||
}).map((t)=>({ | ||
url: e$1.posix.join(r.basePath, t), | ||
revision: getFileHash(e$1.resolve($, t)) | ||
}))), c && (_ ? "string" == typeof d && d.length > 0 && k.push({ | ||
url: d, | ||
revision: t.buildId | ||
}) : k.push({ | ||
url: r.basePath, | ||
revision: t.buildId | ||
})); | ||
let O = e$1.join(t.dir, m); | ||
return e$1.isAbsolute(x) || (x = e$1.join(t.dir, x)), b && !b.document && (b.document = getDefaultDocumentPage(t.dir, r.pageExtensions)), { | ||
disable: p, | ||
register: l, | ||
dest: O, | ||
sw: e$1.posix.join(r.basePath, u), | ||
cacheStartUrl: c, | ||
dynamicStartUrl: _, | ||
dynamicStartUrlRedirect: d, | ||
publicExcludes: f, | ||
fallbacks: b, | ||
cacheOnFrontEndNav: j, | ||
aggressiveFrontEndNavCaching: g, | ||
reloadOnOnline: h, | ||
scope: e$1.posix.join(w, "/"), | ||
customWorkerSrc: x, | ||
customWorkerDest: e$1.resolve(t.dir, A), | ||
customWorkerPrefix: P, | ||
workboxOptions: { | ||
...E, | ||
swDest: e$1.join(O, u), | ||
additionalManifestEntries: t.dev ? [] : k, | ||
exclude: [ | ||
...v, | ||
({ asset: e })=>!!(e.name.startsWith("server/") || e.name.match(/^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/)) || !!t.dev && !e.name.startsWith("static/runtime/") | ||
], | ||
manifestTransforms: [ | ||
...y, | ||
async (s, n)=>{ | ||
let o = relativeToOutputPath$1(n, $), p = `${i}${o}`; | ||
return { | ||
manifest: s.map((s)=>{ | ||
if (s.url = s.url.replace("/_next//static/image", "/_next/static/image").replace("/_next//static/media", "/_next/static/media"), s.url.startsWith(p) && (s.url = e$1.posix.join(r.basePath, s.url.replace(p, ""))), null === s.revision) { | ||
let e = s.url; | ||
"string" == typeof i && e.startsWith(i) && (e = s.url.substring(i.length)); | ||
let r = n.assetsInfo.get(e); | ||
s.revision = r && r.contenthash || t.buildId; | ||
} | ||
return s.url = s.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D"), s; | ||
}), | ||
warnings: [] | ||
}; | ||
} | ||
] | ||
}, | ||
extendDefaultRuntimeCaching: W | ||
}; | ||
}; | ||
const createContext = (t, s, a, n, o)=>{ | ||
"function" == typeof a.webpack && (n = a.webpack(n, s)); | ||
let l = { | ||
...s.config, | ||
basePath: s.config.basePath || "/" | ||
}, m = n.output?.publicPath, u = parseOptions(s, m, l, o); | ||
if (n.plugins || (n.plugins = []), u.disable) return s.isServer || info("PWA support is disabled."), { | ||
disabled: !0, | ||
webpackConfig: n | ||
}; | ||
let c = loadTSConfig(s.dir, l.typescript.tsconfigPath); | ||
n.plugins.push(new t.DefinePlugin({ | ||
__PWA_SW__: `'${u.sw}'`, | ||
__PWA_SCOPE__: `'${u.scope}'`, | ||
__PWA_ENABLE_REGISTER__: `${!!u.register}`, | ||
__PWA_START_URL__: u.dynamicStartUrl ? `'${l.basePath}'` : void 0, | ||
__PWA_CACHE_ON_FRONT_END_NAV__: `${!!u.cacheOnFrontEndNav}`, | ||
__PWA_AGGRFEN_CACHE__: `${!!u.aggressiveFrontEndNavCaching}`, | ||
__PWA_RELOAD_ON_ONLINE__: `${!!u.reloadOnOnline}` | ||
})); | ||
let _ = e$1.join(p, "sw-entry.js"), d = n.entry; | ||
return n.entry = async ()=>{ | ||
let e = await d(); | ||
return e["main.js"] && !e["main.js"].includes(_) && (Array.isArray(e["main.js"]) ? e["main.js"].unshift(_) : "string" == typeof e["main.js"] && (e["main.js"] = [ | ||
_, | ||
e["main.js"] | ||
])), e["main-app"] && !e["main-app"].includes(_) && (Array.isArray(e["main-app"]) ? e["main-app"].unshift(_) : "string" == typeof e["main-app"] && (e["main-app"] = [ | ||
_, | ||
e["main-app"] | ||
])), e; | ||
}, { | ||
disabled: !1, | ||
publicPath: m, | ||
nextConfig: l, | ||
webpack: t, | ||
webpackContext: s, | ||
webpackConfig: n, | ||
tsConfig: c, | ||
userOptions: o, | ||
options: u | ||
}; | ||
};const resolveRuntimeCaching = (o, n)=>{ | ||
if (!o) return t; | ||
if (!n) return info("Custom runtimeCaching array found, using it instead of the default one."), o; | ||
info("Custom runtimeCaching array found, using it to extend the default one."); | ||
let i = [], a = new Set(); | ||
for (let e of o)i.push(e), e.options?.cacheName && a.add(e.options.cacheName); | ||
for (let e of t)e.options?.cacheName && a.has(e.options.cacheName) || i.push(e); | ||
return i; | ||
};const relativeToOutputPath = (o, e)=>e$1.isAbsolute(e) ? e$1.relative(o.options.output.path, e) : e;class ChildCompilationPlugin { | ||
src; | ||
dest; | ||
plugins; | ||
webpack; | ||
constructor({ src: t, dest: i, plugins: s, webpack: e }){ | ||
this.src = t, this.dest = i, this.plugins = s, this.webpack = e; | ||
} | ||
apply(t) { | ||
t.hooks.make.tapPromise(this.constructor.name, (i)=>this.performChildCompilation(i, t).catch((t)=>{ | ||
i.errors.push(t); | ||
})); | ||
} | ||
async performChildCompilation(i, s) { | ||
let e = relativeToOutputPath(i, this.dest), r = i.createChildCompiler(this.constructor.name, { | ||
filename: e | ||
}, []); | ||
if (r.context = s.context, r.inputFileSystem = s.inputFileSystem, r.outputFileSystem = s.outputFileSystem, void 0 !== this.plugins) for (let t of this.plugins)t?.apply(r); | ||
new this.webpack.EntryPlugin(s.context, this.src, this.constructor.name).apply(r), await new Promise((t, s)=>{ | ||
r.runAsChild((e, r, o)=>{ | ||
e ? s(e) : (i.warnings = i.warnings.concat(o?.warnings ?? []), i.errors = i.errors.concat(o?.errors ?? []), t()); | ||
}); | ||
}); | ||
} | ||
}const buildCustomWorker = (s)=>{ | ||
let i = s$1.sync("{src/,}index.{ts,js}", { | ||
cwd: s.options.customWorkerSrc | ||
}); | ||
if (0 === i.length) return; | ||
let m = e$1.join(s.options.customWorkerSrc, i[0]); | ||
event(`Found a custom worker implementation at ${m}.`); | ||
let p = `${s.options.customWorkerPrefix}-${getContentHash(m, s.webpackContext.dev)}.js`; | ||
return event(`Building the custom worker to ${e$1.join(s.options.customWorkerDest, p)}...`), { | ||
name: e$1.posix.join(s.nextConfig.basePath, p), | ||
pluginInstance: new ChildCompilationPlugin({ | ||
src: m, | ||
dest: e$1.join(s.options.customWorkerDest, p), | ||
webpack: s.webpack | ||
}) | ||
}; | ||
};const getFallbackEnvs = ({ fallbacks: L, buildId: e })=>{ | ||
let t = L.data; | ||
t?.endsWith(".json") && (t = e$1.posix.join("/_next/data", e, t)); | ||
let o = { | ||
__PWA_FALLBACK_DOCUMENT__: L.document || !1, | ||
__PWA_FALLBACK_IMAGE__: L.image || !1, | ||
__PWA_FALLBACK_AUDIO__: L.audio || !1, | ||
__PWA_FALLBACK_VIDEO__: L.video || !1, | ||
__PWA_FALLBACK_FONT__: L.font || !1, | ||
__PWA_FALLBACK_DATA__: t || !1 | ||
}; | ||
if (0 !== Object.values(o).filter((_)=>!!_).length) return info("This app will fallback to these precached routes when fetching from the cache and the network fails:"), o.__PWA_FALLBACK_DOCUMENT__ && info(` Documents (pages): ${o.__PWA_FALLBACK_DOCUMENT__}`), o.__PWA_FALLBACK_IMAGE__ && info(` Images: ${o.__PWA_FALLBACK_IMAGE__}`), o.__PWA_FALLBACK_AUDIO__ && info(` Audio: ${o.__PWA_FALLBACK_AUDIO__}`), o.__PWA_FALLBACK_VIDEO__ && info(` Videos: ${o.__PWA_FALLBACK_VIDEO__}`), o.__PWA_FALLBACK_FONT__ && info(` Fonts: ${o.__PWA_FALLBACK_FONT__}`), o.__PWA_FALLBACK_DATA__ && info(` Data (/_next/data/**/*.json): ${o.__PWA_FALLBACK_DATA__}`), o; | ||
};let i = fileURLToPath(new URL(".", import.meta.url)); | ||
const buildFallbackWorker = (t)=>{ | ||
let a = getFallbackEnvs({ | ||
fallbacks: Object.keys(t.options.fallbacks).reduce((n, o)=>{ | ||
let l = t.options.fallbacks[o]; | ||
return l && (n[o] = e$1.posix.join(t.nextConfig.basePath, l)), n; | ||
}, {}), | ||
buildId: t.webpackContext.buildId | ||
}); | ||
if (!a) return; | ||
let s = e$1.join(i, "fallback.js"), r = `fallback-${getContentHash(s, t.webpackContext.dev)}.js`; | ||
return { | ||
name: e$1.posix.join(t.nextConfig.basePath, r), | ||
precaches: Object.values(a).filter((e)=>!!e), | ||
pluginInstance: new ChildCompilationPlugin({ | ||
src: s, | ||
dest: e$1.join(t.options.dest, r), | ||
plugins: [ | ||
new t.webpack.EnvironmentPlugin(a) | ||
], | ||
webpack: t.webpack | ||
}) | ||
}; | ||
};const buildWorkers = (i)=>{ | ||
let s = [], n = buildCustomWorker(i); | ||
i.options.workboxOptions.importScripts || (i.options.workboxOptions.importScripts = []), void 0 !== n && (i.options.workboxOptions.importScripts.unshift(n.name), s.push(n.pluginInstance)); | ||
let r = !1; | ||
if (i.options.fallbacks) { | ||
let o = buildFallbackWorker(i); | ||
if (o) for (let t of (r = !0, i.options.workboxOptions.importScripts.unshift(o.name), s.push(o.pluginInstance), i.options.workboxOptions.additionalManifestEntries || (i.options.workboxOptions.additionalManifestEntries = []), o.precaches))t && "boolean" != typeof t && !i.options.workboxOptions.additionalManifestEntries.find((o)=>"object" == typeof o && o.url.startsWith(t)) && i.options.workboxOptions.additionalManifestEntries.push({ | ||
url: t, | ||
revision: i.webpackContext.buildId | ||
}); | ||
} | ||
return { | ||
hasFallbacks: r, | ||
childCompilationInstances: s | ||
}; | ||
};const resolveWorkboxPlugin = (a)=>{ | ||
let p; | ||
if (isInjectManifestConfig(a.options.workboxOptions)) { | ||
let n = e$1.join(a.webpackContext.dir, a.options.workboxOptions.swSrc); | ||
event(`Using InjectManifest with ${n}`); | ||
let i = new o$2.InjectManifest({ | ||
...a.options.workboxOptions, | ||
swSrc: n | ||
}); | ||
return a.webpackContext.dev && overrideAfterCalledMethod(i), [ | ||
i | ||
]; | ||
} | ||
let { hasFallbacks: l, childCompilationInstances: c } = buildWorkers(a), { skipWaiting: d = !0, clientsClaim: u = !0, cleanupOutdatedCaches: h = !0, ignoreURLParametersMatching: f = [ | ||
/^utm_/, | ||
/^fbclid$/ | ||
], importScripts: m, runtimeCaching: b, ...w } = a.options.workboxOptions, k = !1; | ||
a.webpackContext.dev ? (info("Building in development mode, caching and precaching are disabled for the most part. This means that offline support is disabled, but you can continue developing other functions in service worker."), f.push(/ts/), p = [ | ||
{ | ||
urlPattern: /.*/i, | ||
handler: "NetworkOnly", | ||
options: { | ||
cacheName: "dev" | ||
} | ||
} | ||
], k = !0) : p = resolveRuntimeCaching(b, a.options.extendDefaultRuntimeCaching), a.options.dynamicStartUrl && p.unshift({ | ||
urlPattern: a.nextConfig.basePath, | ||
handler: "NetworkFirst", | ||
options: { | ||
cacheName: "start-url", | ||
plugins: [ | ||
{ | ||
cacheWillUpdate: async ({ response: e })=>e && "opaqueredirect" === e.type ? new Response(e.body, { | ||
status: 200, | ||
statusText: "OK", | ||
headers: e.headers | ||
}) : e | ||
} | ||
] | ||
} | ||
}), l && p.forEach((e)=>{ | ||
!e.options || e.options.precacheFallback || e.options.plugins?.find((e)=>"handlerDidError" in e) || (e.options.plugins || (e.options.plugins = []), e.options.plugins.push({ | ||
handlerDidError: async ({ request: e })=>"undefined" != typeof self ? self.fallback(e) : Response.error() | ||
})); | ||
}); | ||
let g = new o$2.GenerateSW({ | ||
...w, | ||
skipWaiting: d, | ||
clientsClaim: u, | ||
cleanupOutdatedCaches: h, | ||
ignoreURLParametersMatching: f, | ||
importScripts: m, | ||
runtimeCaching: p | ||
}); | ||
return k && overrideAfterCalledMethod(g), [ | ||
g, | ||
...c | ||
]; | ||
};let r = fileURLToPath(new URL(".", import.meta.url)); | ||
const buildSWEntryWorker = (e)=>{ | ||
if (!e.options.cacheOnFrontEndNav) return; | ||
let i = e$1.join(r, "sw-entry-worker.js"), s = `swe-worker-${getContentHash(i, e.webpackContext.dev)}.js`; | ||
return { | ||
name: e$1.posix.join(e.nextConfig.basePath, s), | ||
pluginInstance: new ChildCompilationPlugin({ | ||
src: i, | ||
dest: e$1.join(e.options.dest, s), | ||
webpack: e.webpack | ||
}) | ||
}; | ||
};var index = ((n = {})=>(p = {})=>({ | ||
...p, | ||
webpack (a, c) { | ||
let w = createContext(c.webpack, c, p, a, n); | ||
if (w.disabled) return w.webpackConfig; | ||
if (w.webpackConfig.plugins || (w.webpackConfig.plugins = []), event(`Compiling for ${c.isServer ? "server" : "client (static)"}...`), !c.isServer) { | ||
let n = buildSWEntryWorker(w); | ||
w.webpackConfig.plugins.push(new w.webpack.DefinePlugin({ | ||
__PWA_SW_ENTRY_WORKER__: n?.name && `'${n.name}'` | ||
}), ...n ? [ | ||
n.pluginInstance | ||
] : []), w.options.register || (info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:"), info(" window.workbox.register()"), w.tsConfig?.compilerOptions?.types?.includes("@ducanh2912/next-pwa/workbox") || info("You may also want to add @ducanh2912/next-pwa/workbox to compilerOptions.types in your tsconfig.json/jsconfig.json.")), info(`Service worker: ${e$1.join(w.options.dest, w.options.sw)}`), info(` URL: ${w.options.sw}`), info(` Scope: ${w.options.scope}`), w.webpackConfig.plugins.push(new CleanWebpackPlugin({ | ||
cleanOnceBeforeBuildPatterns: [ | ||
e$1.join(w.options.dest, "{workbox,fallback,swe-worker,worker}-*.js"), | ||
e$1.join(w.options.dest, "{workbox,fallback,swe-worker,worker}-*.js.map"), | ||
e$1.join(w.options.dest, w.options.sw), | ||
e$1.join(w.options.dest, `${w.options.sw}.map`), | ||
e$1.join(w.options.customWorkerDest, `${w.options.customWorkerPrefix}-*.js`), | ||
e$1.join(w.options.customWorkerDest, `${w.options.customWorkerPrefix}-*.js.map`) | ||
] | ||
})), w.webpackConfig.plugins.push(...resolveWorkboxPlugin(w)); | ||
} | ||
return w.webpackConfig; | ||
} | ||
}));export{index as default,t as runtimeCaching}; |
@@ -1,1 +0,31 @@ | ||
self.onmessage=async e=>{switch(e.data.type){case"__START_URL_CACHE__":{let t=e.data.url,a=await fetch(t);if(!a.redirected)return (await caches.open("start-url")).put(t,a);return Promise.resolve()}case"__FRONTEND_NAV_CACHE__":{let t=e.data.url,a=await caches.open("pages");if(await a.match(t,{ignoreSearch:!0}))return;let s=await fetch(t);if(!s.ok)return;if(a.put(t,s.clone()),e.data.shouldCacheAggressively&&s.headers.get("Content-Type")?.includes("text/html"))try{let e=await s.text(),t=[],a=await caches.open("static-style-assets"),r=await caches.open("next-static-js-assets"),c=await caches.open("static-js-assets");for(let[s,r]of e.matchAll(/<link.*?href=['"](.*?)['"].*?>/g))/rel=['"]stylesheet['"]/.test(s)&&t.push(a.match(r).then(e=>e?Promise.resolve():a.add(r)));for(let[,a]of e.matchAll(/<script.*?src=['"](.*?)['"].*?>/g)){let e=/\/_next\/static.+\.js$/i.test(a)?r:c;t.push(e.match(a).then(t=>t?Promise.resolve():e.add(a)));}return await Promise.all(t)}catch{}return Promise.resolve()}default:return Promise.resolve()}}; | ||
self.onmessage = async (e)=>{ | ||
switch(e.data.type){ | ||
case "__START_URL_CACHE__": | ||
{ | ||
let t = e.data.url, a = await fetch(t); | ||
if (!a.redirected) return (await caches.open("start-url")).put(t, a); | ||
return Promise.resolve(); | ||
} | ||
case "__FRONTEND_NAV_CACHE__": | ||
{ | ||
let t = e.data.url, a = await caches.open("pages"); | ||
if (await a.match(t, { | ||
ignoreSearch: !0 | ||
})) return; | ||
let s = await fetch(t); | ||
if (!s.ok) return; | ||
if (a.put(t, s.clone()), e.data.shouldCacheAggressively && s.headers.get("Content-Type")?.includes("text/html")) try { | ||
let e = await s.text(), t = [], a = await caches.open("static-style-assets"), r = await caches.open("next-static-js-assets"), c = await caches.open("static-js-assets"); | ||
for (let [s, r] of e.matchAll(/<link.*?href=['"](.*?)['"].*?>/g))/rel=['"]stylesheet['"]/.test(s) && t.push(a.match(r).then((e)=>e ? Promise.resolve() : a.add(r))); | ||
for (let [, a] of e.matchAll(/<script.*?src=['"](.*?)['"].*?>/g)){ | ||
let e = /\/_next\/static.+\.js$/i.test(a) ? r : c; | ||
t.push(e.match(a).then((t)=>t ? Promise.resolve() : e.add(a))); | ||
} | ||
return await Promise.all(t); | ||
} catch {} | ||
return Promise.resolve(); | ||
} | ||
default: | ||
return Promise.resolve(); | ||
} | ||
}; |
@@ -1,1 +0,37 @@ | ||
import {Workbox}from'workbox-window';if("undefined"!=typeof window&&"serviceWorker"in navigator&&"undefined"!=typeof caches){let e;if(__PWA_SW_ENTRY_WORKER__&&(e=new Worker(__PWA_SW_ENTRY_WORKER__)),window.workbox=new Workbox(window.location.origin+__PWA_SW__,{scope:__PWA_SCOPE__}),__PWA_ENABLE_REGISTER__&&window.workbox.register(),__PWA_CACHE_ON_FRONT_END_NAV__||__PWA_START_URL__){let _=async _=>{if(!window.navigator.onLine||!_)return;let t=_ instanceof URL?_.toString():"string"==typeof _?_:void 0;if("string"==typeof t){if(__PWA_START_URL__&&t===__PWA_START_URL__){if(e)e.postMessage({type:"__START_URL_CACHE__",url:t});else {let e=await fetch(_);if(!e.redirected)return (await caches.open("start-url")).put(_,e)}}else __PWA_CACHE_ON_FRONT_END_NAV__&&e?.postMessage({type:"__FRONTEND_NAV_CACHE__",shouldCacheAggressively:__PWA_AGGRFEN_CACHE__,url:t});}},t=history.pushState;history.pushState=(...e)=>{t.apply(history,e),_(e[2]);};let o=history.replaceState;history.replaceState=(...e)=>{o.apply(history,e),_(e[2]);},window.addEventListener("online",()=>{_(window.location.pathname);});}__PWA_RELOAD_ON_ONLINE__&&window.addEventListener("online",()=>location.reload());} | ||
import {Workbox}from'workbox-window';if ("undefined" != typeof window && "serviceWorker" in navigator && "undefined" != typeof caches) { | ||
let e; | ||
if (__PWA_SW_ENTRY_WORKER__ && (e = new Worker(__PWA_SW_ENTRY_WORKER__)), window.workbox = new Workbox(window.location.origin + __PWA_SW__, { | ||
scope: __PWA_SCOPE__ | ||
}), __PWA_ENABLE_REGISTER__ && window.workbox.register(), __PWA_CACHE_ON_FRONT_END_NAV__ || __PWA_START_URL__) { | ||
let _ = async (_)=>{ | ||
if (!window.navigator.onLine || !_) return; | ||
let t = _ instanceof URL ? _.toString() : "string" == typeof _ ? _ : void 0; | ||
if ("string" == typeof t) { | ||
if (__PWA_START_URL__ && t === __PWA_START_URL__) { | ||
if (e) e.postMessage({ | ||
type: "__START_URL_CACHE__", | ||
url: t | ||
}); | ||
else { | ||
let e = await fetch(_); | ||
if (!e.redirected) return (await caches.open("start-url")).put(_, e); | ||
} | ||
} else __PWA_CACHE_ON_FRONT_END_NAV__ && e?.postMessage({ | ||
type: "__FRONTEND_NAV_CACHE__", | ||
shouldCacheAggressively: __PWA_AGGRFEN_CACHE__, | ||
url: t | ||
}); | ||
} | ||
}, t = history.pushState; | ||
history.pushState = (...e)=>{ | ||
t.apply(history, e), _(e[2]); | ||
}; | ||
let o = history.replaceState; | ||
history.replaceState = (...e)=>{ | ||
o.apply(history, e), _(e[2]); | ||
}, window.addEventListener("online", ()=>{ | ||
_(window.location.pathname); | ||
}); | ||
} | ||
__PWA_RELOAD_ON_ONLINE__ && window.addEventListener("online", ()=>location.reload()); | ||
} |
{ | ||
"name": "@ducanh2912/next-pwa", | ||
"version": "10.2.5", | ||
"version": "10.2.6", | ||
"type": "module", | ||
"private": false, | ||
"description": "PWA for Next.js, powered by Workbox.", | ||
"repository": "https://github.com/DuCanhGH/next-pwa", | ||
"keywords": [ | ||
"nextjs", | ||
"pwa", | ||
"workbox", | ||
"web", | ||
"service-worker" | ||
], | ||
"author": "ShadowWalker <w@weiw.io>, DuCanhGH", | ||
"license": "MIT", | ||
"private": false, | ||
"repository": "https://gitlab.com/serwist/next-pwa", | ||
"bugs": "https://gitlab.com/serwist/next-pwa/issues", | ||
"homepage": "https://ducanh2912-next-pwa.vercel.app", | ||
"files": [ | ||
@@ -48,13 +57,6 @@ "dist", | ||
}, | ||
"keywords": [ | ||
"nextjs", | ||
"pwa", | ||
"workbox", | ||
"web", | ||
"service-worker" | ||
], | ||
"dependencies": { | ||
"clean-webpack-plugin": "4.0.0", | ||
"fast-glob": "3.3.2", | ||
"semver": "7.5.4", | ||
"semver": "7.6.0", | ||
"terser-webpack-plugin": "5.3.10", | ||
@@ -67,19 +69,13 @@ "workbox-build": "7.0.0", | ||
"devDependencies": { | ||
"@rollup/plugin-alias": "5.1.0", | ||
"@rollup/plugin-json": "6.1.0", | ||
"@rollup/plugin-node-resolve": "15.2.3", | ||
"@rollup/plugin-swc": "0.3.0", | ||
"@rollup/plugin-typescript": "11.1.5", | ||
"@swc/core": "1.3.102", | ||
"@types/node": "20.10.6", | ||
"@types/semver": "7.5.6", | ||
"@types/node": "20.12.4", | ||
"@types/semver": "7.5.8", | ||
"chalk": "5.3.0", | ||
"next": "14.0.5-canary.37", | ||
"react": "18.3.0-canary-1d5667a12-20240102", | ||
"react-dom": "18.3.0-canary-1d5667a12-20240102", | ||
"next": "14.2.0-canary.56", | ||
"rollup": "3.28.1", | ||
"rollup-plugin-dts": "6.0.2", | ||
"type-fest": "4.9.0", | ||
"typescript": "5.4.0-dev.20240104", | ||
"webpack": "5.89.0" | ||
"react": "19.0.0-canary-7a2609eed-20240403", | ||
"react-dom": "19.0.0-canary-7a2609eed-20240403", | ||
"type-fest": "4.15.0", | ||
"typescript": "5.5.0-dev.20240404", | ||
"webpack": "5.91.0", | ||
"@serwist/configs": "10.2.5" | ||
}, | ||
@@ -86,0 +82,0 @@ "peerDependencies": { |
@@ -22,6 +22,4 @@ # Zero-config [PWA](https://web.dev/learn/pwa/) plugin for [Next.js](https://nextjs.org/) | ||
You can ask questions, suggest features, and share your projects on [Github Discussions](https://github.com/DuCanhGH/next-pwa/discussions). | ||
You can ask questions and suggest features. Please follow our [Code of Conduct](/CODE_OF_CONDUCT.md) when you communicate with other people. | ||
Please follow our [Code of Conduct](/CODE_OF_CONDUCT.md) when you communicate with other people. | ||
## Contributing | ||
@@ -28,0 +26,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
105448
11
2498
1
35
7
+ Added@types/node@20.12.8(transitive)
+ Addedcaniuse-lite@1.0.30001615(transitive)
+ Addedelectron-to-chromium@1.4.754(transitive)
+ Addedjake@10.8.7(transitive)
+ Addedsemver@7.6.0(transitive)
+ Addedupdate-browserslist-db@1.0.14(transitive)
- Removed@types/node@20.12.10(transitive)
- Removedcaniuse-lite@1.0.30001616(transitive)
- Removedelectron-to-chromium@1.4.757(transitive)
- Removedjake@10.9.1(transitive)
- Removedsemver@7.5.4(transitive)
- Removedupdate-browserslist-db@1.0.15(transitive)
Updatedsemver@7.6.0