@serwist/next 8.4.4 → 9.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -37
- package/dist/index.worker.d.ts +5 -0
- package/dist/index.worker.d.ts.map +1 -0
- package/dist/{index.browser.cjs → index.worker.js} +57 -22
- package/dist/internal-types.d.ts +6 -0
- package/dist/internal-types.d.ts.map +1 -0
- package/dist/sw-entry-worker.d.ts +1 -0
- package/dist/sw-entry-worker.d.ts.map +1 -0
- package/dist/sw-entry.d.ts +1 -0
- package/dist/sw-entry.d.ts.map +1 -0
- package/dist/utils/find-first-truthy.d.ts +1 -0
- package/dist/utils/find-first-truthy.d.ts.map +1 -0
- package/dist/utils/get-content-hash.d.ts +1 -0
- package/dist/utils/get-content-hash.d.ts.map +1 -0
- package/dist/utils/get-file-hash.d.ts +1 -0
- package/dist/utils/get-file-hash.d.ts.map +1 -0
- package/dist/utils/get-package-version.d.ts +1 -0
- package/dist/utils/get-package-version.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/load-tsconfig.d.ts +1 -0
- package/dist/utils/load-tsconfig.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/worker/defaultCache.d.ts +3 -0
- package/dist/worker/defaultCache.d.ts.map +1 -0
- package/dist/worker/definePageRuntimeCaching.d.ts +16 -0
- package/dist/worker/definePageRuntimeCaching.d.ts.map +1 -0
- package/package.json +47 -49
- package/src/index.ts +241 -0
- package/src/index.worker.ts +5 -0
- package/src/internal-types.ts +17 -0
- package/src/sw-entry-worker.ts +46 -0
- package/src/sw-entry.ts +64 -0
- package/src/utils/find-first-truthy.ts +15 -0
- package/src/utils/get-content-hash.ts +10 -0
- package/src/utils/get-file-hash.ts +4 -0
- package/src/utils/get-package-version.ts +16 -0
- package/src/utils/load-tsconfig.ts +27 -0
- package/src/utils/logger.ts +57 -0
- package/src/utils.ts +11 -0
- package/src/worker/defaultCache.ts +223 -0
- package/src/worker/definePageRuntimeCaching.ts +36 -0
- package/dist/index.browser.d.cts +0 -2
- package/dist/index.browser.d.ts +0 -2
- package/dist/index.browser.js +0 -208
- package/dist/index.cjs +0 -928
- package/dist/index.d.cts +0 -5
- package/dist/internal-types.d.cts +0 -9
- package/dist/sw-entry-worker.cjs +0 -35
- package/dist/sw-entry-worker.d.cts +0 -7
- package/dist/sw-entry.cjs +0 -43
- package/dist/sw-entry.d.cts +0 -6
- package/dist/types.d.cts +0 -81
- package/dist/types.d.ts +0 -81
- package/dist/utils/find-first-truthy.d.cts +0 -7
- package/dist/utils/get-content-hash.d.cts +0 -3
- package/dist/utils/get-file-hash.d.cts +0 -3
- package/dist/utils/get-package-version.d.cts +0 -6
- package/dist/utils/load-tsconfig.d.cts +0 -2
- package/dist/utils/logger.d.cts +0 -5
- package/dist/utils.d.cts +0 -4
- /package/{dist/utils/index.d.cts → src/utils/index.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { NextInjectManifestOptions } from "@serwist/build";
|
|
1
2
|
import type { NextConfig } from "next";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
3
|
+
declare const withSerwistInit: (pluginOptions: NextInjectManifestOptions) => (nextConfig?: NextConfig) => NextConfig;
|
|
4
|
+
export default withSerwistInit;
|
|
5
|
+
export type { NextInjectManifestOptions as PluginOptions };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAMhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQvC,QAAA,MAAM,eAAe,kBAAmB,yBAAyB,mBAAkB,UAAU,KAAK,UA4NjG,CAAC;AAEF,eAAe,eAAe,CAAC;AAC/B,YAAY,EAAE,yBAAyB,IAAI,aAAa,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { validateNextInjectManifestOptions } from '@serwist/build/next';
|
|
3
4
|
import { InjectManifest } from '@serwist/webpack-plugin';
|
|
4
|
-
import { ChildCompilationPlugin } from '@serwist/webpack-plugin/internal';
|
|
5
|
+
import { ChildCompilationPlugin, relativeToOutputPath } from '@serwist/webpack-plugin/internal';
|
|
5
6
|
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
6
7
|
import fg from 'fast-glob';
|
|
7
8
|
import crypto from 'node:crypto';
|
|
@@ -719,7 +720,6 @@ const chalk = createChalk();
|
|
|
719
720
|
createChalk({
|
|
720
721
|
level: stderrColor ? stderrColor.level : 0
|
|
721
722
|
});
|
|
722
|
-
var chalk$1 = chalk;
|
|
723
723
|
|
|
724
724
|
const mapLoggingMethodToConsole = {
|
|
725
725
|
wait: "log",
|
|
@@ -729,11 +729,11 @@ const mapLoggingMethodToConsole = {
|
|
|
729
729
|
event: "log"
|
|
730
730
|
};
|
|
731
731
|
const prefixes = {
|
|
732
|
-
wait: `${chalk
|
|
733
|
-
error: `${chalk
|
|
734
|
-
warn: `${chalk
|
|
735
|
-
info: `${chalk
|
|
736
|
-
event: `${chalk
|
|
732
|
+
wait: `${chalk.white(chalk.bold("○"))} (serwist)`,
|
|
733
|
+
error: `${chalk.red(chalk.bold("X"))} (serwist)`,
|
|
734
|
+
warn: `${chalk.yellow(chalk.bold("⚠"))} (serwist)`,
|
|
735
|
+
info: `${chalk.white(chalk.bold("○"))} (serwist)`,
|
|
736
|
+
event: `${chalk.green(chalk.bold("✓"))} (serwist)`
|
|
737
737
|
};
|
|
738
738
|
const prefixedLog = (prefixType, ...message)=>{
|
|
739
739
|
const consoleMethod = mapLoggingMethodToConsole[prefixType];
|
|
@@ -756,15 +756,15 @@ const event = (...message)=>{
|
|
|
756
756
|
};
|
|
757
757
|
|
|
758
758
|
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
759
|
-
const
|
|
759
|
+
const withSerwistInit = (pluginOptions)=>{
|
|
760
760
|
return (nextConfig = {})=>({
|
|
761
761
|
...nextConfig,
|
|
762
762
|
webpack (config, options) {
|
|
763
763
|
const webpack = options.webpack;
|
|
764
|
-
const {
|
|
764
|
+
const { dev } = options;
|
|
765
765
|
const basePath = options.config.basePath || "/";
|
|
766
766
|
const tsConfigJson = loadTSConfig(options.dir, nextConfig?.typescript?.tsconfigPath);
|
|
767
|
-
const { cacheOnFrontEndNav
|
|
767
|
+
const { cacheOnFrontEndNav, disable, scope = basePath, swUrl, register, reloadOnOnline, globPublicPatterns, ...buildOptions } = validateNextInjectManifestOptions(pluginOptions);
|
|
768
768
|
if (typeof nextConfig.webpack === "function") {
|
|
769
769
|
config = nextConfig.webpack(config, options);
|
|
770
770
|
}
|
|
@@ -781,9 +781,9 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
781
781
|
config.plugins.push(new webpack.DefinePlugin({
|
|
782
782
|
"self.__SERWIST_SW_ENTRY.sw": `'${_sw}'`,
|
|
783
783
|
"self.__SERWIST_SW_ENTRY.scope": `'${_scope}'`,
|
|
784
|
-
"self.__SERWIST_SW_ENTRY.cacheOnFrontEndNav": `${
|
|
785
|
-
"self.__SERWIST_SW_ENTRY.register": `${
|
|
786
|
-
"self.__SERWIST_SW_ENTRY.reloadOnOnline": `${
|
|
784
|
+
"self.__SERWIST_SW_ENTRY.cacheOnFrontEndNav": `${cacheOnFrontEndNav}`,
|
|
785
|
+
"self.__SERWIST_SW_ENTRY.register": `${register}`,
|
|
786
|
+
"self.__SERWIST_SW_ENTRY.reloadOnOnline": `${reloadOnOnline}`
|
|
787
787
|
}));
|
|
788
788
|
const swEntryJs = path.join(__dirname, "sw-entry.js");
|
|
789
789
|
const entry = config.entry;
|
|
@@ -822,20 +822,25 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
822
822
|
const { swSrc: providedSwSrc, swDest: providedSwDest, additionalPrecacheEntries, exclude = [], manifestTransforms = [], ...otherBuildOptions } = buildOptions;
|
|
823
823
|
let swSrc = providedSwSrc;
|
|
824
824
|
let swDest = providedSwDest;
|
|
825
|
+
// If these two paths are not absolute, they will be resolved from `compilation.options.output.path`,
|
|
826
|
+
// which is `${options.dir}/${nextConfig.destDir}` for Next.js apps, rather than `${options.dir}`
|
|
827
|
+
// as an user would expect.
|
|
825
828
|
if (!path.isAbsolute(swSrc)) {
|
|
826
829
|
swSrc = path.join(options.dir, swSrc);
|
|
827
830
|
}
|
|
828
831
|
if (!path.isAbsolute(swDest)) {
|
|
829
832
|
swDest = path.join(options.dir, swDest);
|
|
830
833
|
}
|
|
834
|
+
const publicDir = path.resolve(options.dir, "public");
|
|
831
835
|
const destDir = path.dirname(swDest);
|
|
832
836
|
const shouldBuildSWEntryWorker = cacheOnFrontEndNav;
|
|
833
837
|
let swEntryPublicPath = undefined;
|
|
838
|
+
let swEntryWorkerDest = undefined;
|
|
834
839
|
if (shouldBuildSWEntryWorker) {
|
|
835
840
|
const swEntryWorkerSrc = path.join(__dirname, "sw-entry-worker.js");
|
|
836
841
|
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
837
842
|
swEntryPublicPath = path.posix.join(basePath, swEntryName);
|
|
838
|
-
|
|
843
|
+
swEntryWorkerDest = path.join(destDir, swEntryName);
|
|
839
844
|
config.plugins.push(new ChildCompilationPlugin({
|
|
840
845
|
src: swEntryWorkerSrc,
|
|
841
846
|
dest: swEntryWorkerDest
|
|
@@ -858,18 +863,24 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
858
863
|
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
859
864
|
if (!resolvedManifestEntries) {
|
|
860
865
|
const swDestFileName = path.basename(swDest);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
866
|
+
const userPublicGlob = typeof globPublicPatterns === "string" ? [
|
|
867
|
+
globPublicPatterns
|
|
868
|
+
] : globPublicPatterns ?? [
|
|
869
|
+
"**/*"
|
|
870
|
+
];
|
|
871
|
+
const publicScan = fg.sync([
|
|
872
|
+
...userPublicGlob,
|
|
873
|
+
// Forcibly include these in case the user outputs these files to `public`.
|
|
864
874
|
"!swe-worker-*.js",
|
|
865
875
|
"!swe-worker-*.js.map",
|
|
866
876
|
`!${swDestFileName.replace(/^\/+/, "")}`,
|
|
867
877
|
`!${swDestFileName.replace(/^\/+/, "")}.map`
|
|
868
878
|
], {
|
|
869
|
-
cwd:
|
|
870
|
-
})
|
|
879
|
+
cwd: publicDir
|
|
880
|
+
});
|
|
881
|
+
resolvedManifestEntries = publicScan.map((f)=>({
|
|
871
882
|
url: path.posix.join(basePath, f),
|
|
872
|
-
revision: getFileHash(
|
|
883
|
+
revision: getFileHash(path.join(publicDir, f))
|
|
873
884
|
}));
|
|
874
885
|
}
|
|
875
886
|
const publicPath = config.output?.publicPath;
|
|
@@ -880,28 +891,30 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
880
891
|
additionalPrecacheEntries: dev ? [] : resolvedManifestEntries,
|
|
881
892
|
exclude: [
|
|
882
893
|
...exclude,
|
|
883
|
-
({ asset })=>{
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
return false;
|
|
894
|
+
({ asset, compilation })=>{
|
|
895
|
+
// Same as how `@serwist/webpack-plugin` does it. It is always
|
|
896
|
+
// `relativeToOutputPath(compilation, originalSwDest)`.
|
|
897
|
+
const swDestRelativeOutput = relativeToOutputPath(compilation, swDest);
|
|
898
|
+
const swAsset = compilation.getAsset(swDestRelativeOutput);
|
|
899
|
+
return(// We don't need the service worker to be cached.
|
|
900
|
+
asset.name === swAsset?.name || asset.name.startsWith("server/") || /^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/.test(asset.name) || dev && !asset.name.startsWith("static/runtime/"));
|
|
891
901
|
}
|
|
892
902
|
],
|
|
893
903
|
manifestTransforms: [
|
|
894
904
|
...manifestTransforms,
|
|
895
905
|
async (manifestEntries, compilation)=>{
|
|
906
|
+
// This path always uses forward slashes, so it is safe to use it in the following string replace.
|
|
907
|
+
const publicDirRelativeOutput = relativeToOutputPath(compilation, publicDir);
|
|
908
|
+
// `publicPath` is always `${assetPrefix}/_next/` for Next.js apps.
|
|
909
|
+
const publicFilesPrefix = `${publicPath}${publicDirRelativeOutput}`;
|
|
896
910
|
const manifest = manifestEntries.map((m)=>{
|
|
897
|
-
m.url = m.url.replace("/_next//static/image", "/_next/static/image").replace("/_next//static/media", "/_next/static/media")
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
m.revision = asset ? asset.contenthash || buildId : buildId;
|
|
911
|
+
m.url = m.url.replace("/_next//static/image", "/_next/static/image").replace("/_next//static/media", "/_next/static/media");
|
|
912
|
+
// We remove `${publicPath}/${publicDirRelativeOutput}` because `assetPrefix`
|
|
913
|
+
// is not intended for files that are in the public directory and we also want
|
|
914
|
+
// to remove `/_next/${publicDirRelativeOutput}` from the URL, since that is not how
|
|
915
|
+
// we resolve files in the public directory.
|
|
916
|
+
if (m.url.startsWith(publicFilesPrefix)) {
|
|
917
|
+
m.url = path.posix.join(basePath, m.url.replace(publicFilesPrefix, ""));
|
|
905
918
|
}
|
|
906
919
|
m.url = m.url.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
|
|
907
920
|
return m;
|
|
@@ -920,4 +933,4 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
920
933
|
});
|
|
921
934
|
};
|
|
922
935
|
|
|
923
|
-
export {
|
|
936
|
+
export { withSerwistInit as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { defaultCache } from "./worker/defaultCache.js";
|
|
2
|
+
import { type DefinePageRuntimeCachingOptions, type PageRuntimeCaching, definePageRuntimeCaching } from "./worker/definePageRuntimeCaching.js";
|
|
3
|
+
export { defaultCache, definePageRuntimeCaching };
|
|
4
|
+
export type { DefinePageRuntimeCachingOptions, PageRuntimeCaching };
|
|
5
|
+
//# sourceMappingURL=index.worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.worker.d.ts","sourceRoot":"","sources":["../src/index.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,+BAA+B,EAAE,KAAK,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAE/I,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAClD,YAAY,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
const nonNullable = (value)=>value !== null && value !== undefined;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Conveniently define three `runtimeCaching` entries for Next.js pages.
|
|
5
|
+
* @param options
|
|
6
|
+
* @returns
|
|
7
|
+
*/ const definePageRuntimeCaching = ({ rscPrefetch, rsc, html })=>{
|
|
8
|
+
const pageRcs = [
|
|
9
|
+
rscPrefetch,
|
|
10
|
+
rsc,
|
|
11
|
+
html
|
|
12
|
+
];
|
|
13
|
+
if (pageRcs[0]) {
|
|
14
|
+
if (!pageRcs[0].options) pageRcs[0].options = {};
|
|
15
|
+
pageRcs[0].options.cacheName = "pages-rsc-prefetch";
|
|
16
|
+
}
|
|
17
|
+
if (pageRcs[1]) {
|
|
18
|
+
if (!pageRcs[1].options) pageRcs[1].options = {};
|
|
19
|
+
pageRcs[1].options.cacheName = "pages-rsc";
|
|
20
|
+
}
|
|
21
|
+
if (pageRcs[2]) {
|
|
22
|
+
if (!pageRcs[2].options) pageRcs[2].options = {};
|
|
23
|
+
pageRcs[2].options.cacheName = "pages";
|
|
24
|
+
}
|
|
25
|
+
return pageRcs.filter(nonNullable);
|
|
26
|
+
};
|
|
2
27
|
|
|
3
28
|
// Serwist RuntimeCaching config: https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.RuntimeCachingEntry
|
|
4
29
|
const defaultCache = [
|
|
@@ -160,33 +185,43 @@ const defaultCache = [
|
|
|
160
185
|
networkTimeoutSeconds: 10
|
|
161
186
|
}
|
|
162
187
|
},
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
188
|
+
...definePageRuntimeCaching({
|
|
189
|
+
rscPrefetch: {
|
|
190
|
+
urlPattern: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("RSC") === "1" && request.headers.get("Next-Router-Prefetch") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
191
|
+
handler: "NetworkFirst",
|
|
192
|
+
options: {
|
|
193
|
+
expiration: {
|
|
194
|
+
maxEntries: 32,
|
|
195
|
+
maxAgeSeconds: 24 * 60 * 60
|
|
196
|
+
}
|
|
171
197
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
198
|
+
},
|
|
199
|
+
rsc: {
|
|
200
|
+
urlPattern: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("RSC") === "1" && sameOrigin && !pathname.startsWith("/api/"),
|
|
201
|
+
handler: "NetworkFirst",
|
|
202
|
+
options: {
|
|
203
|
+
expiration: {
|
|
204
|
+
maxEntries: 32,
|
|
205
|
+
maxAgeSeconds: 24 * 60 * 60
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
html: {
|
|
210
|
+
urlPattern: ({ request, url: { pathname }, sameOrigin })=>request.headers.get("Content-Type")?.includes("text/html") && sameOrigin && !pathname.startsWith("/api/"),
|
|
211
|
+
handler: "NetworkFirst",
|
|
212
|
+
options: {
|
|
213
|
+
expiration: {
|
|
214
|
+
maxEntries: 32,
|
|
215
|
+
maxAgeSeconds: 24 * 60 * 60
|
|
216
|
+
}
|
|
182
217
|
}
|
|
183
218
|
}
|
|
184
|
-
},
|
|
219
|
+
}),
|
|
185
220
|
{
|
|
186
221
|
urlPattern: ({ url: { pathname }, sameOrigin })=>sameOrigin && !pathname.startsWith("/api/"),
|
|
187
222
|
handler: "NetworkFirst",
|
|
188
223
|
options: {
|
|
189
|
-
cacheName: "
|
|
224
|
+
cacheName: "others",
|
|
190
225
|
expiration: {
|
|
191
226
|
maxEntries: 32,
|
|
192
227
|
maxAgeSeconds: 24 * 60 * 60
|
|
@@ -207,4 +242,4 @@ const defaultCache = [
|
|
|
207
242
|
}
|
|
208
243
|
];
|
|
209
244
|
|
|
210
|
-
|
|
245
|
+
export { defaultCache, definePageRuntimeCaching };
|
package/dist/internal-types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Asset, Compilation } from "webpack";
|
|
1
2
|
export type SerwistNextOptionsKey = "self.__SERWIST_SW_ENTRY";
|
|
2
3
|
export interface SerwistNextOptions {
|
|
3
4
|
sw: string;
|
|
@@ -7,3 +8,8 @@ export interface SerwistNextOptions {
|
|
|
7
8
|
reloadOnOnline: boolean;
|
|
8
9
|
swEntryWorker: string | undefined;
|
|
9
10
|
}
|
|
11
|
+
export interface ExcludeParams {
|
|
12
|
+
asset: Asset;
|
|
13
|
+
compilation: Compilation;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=internal-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../src/internal-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sw-entry-worker.d.ts","sourceRoot":"","sources":["../src/sw-entry-worker.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GACnB;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;CACnB,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/sw-entry.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sw-entry.d.ts","sourceRoot":"","sources":["../src/sw-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,CAAC;KAClB;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-first-truthy.d.ts","sourceRoot":"","sources":["../../src/utils/find-first-truthy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mEAQ3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-content-hash.d.ts","sourceRoot":"","sources":["../../src/utils/get-content-hash.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAI9B,eAAO,MAAM,cAAc,SAAU,GAAG,oBAAoB,SAAS,OAAO,WAK3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-file-hash.d.ts","sourceRoot":"","sources":["../../src/utils/get-file-hash.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,SAAU,GAAG,oBAAoB,WAAyE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-version.d.ts","sourceRoot":"","sources":["../../src/utils/get-package-version.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,gBAAiB,MAAM,KAAG,MAAM,GAAG,SAMhE,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-tsconfig.d.ts","sourceRoot":"","sources":["../../src/utils/load-tsconfig.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9D,eAAO,MAAM,YAAY,YAAa,MAAM,wBAAwB,MAAM,GAAG,SAAS,KAAG,YAAY,GAAG,SAmBvG,CAAC"}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,IAAI,eAAgB,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,eAAgB,GAAG,EAAE,SAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,eAAgB,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,IAAI,eAAgB,GAAG,EAAE,SAErC,CAAC;AAEF,eAAO,MAAM,KAAK,eAAgB,GAAG,EAAE,SAEtC,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,eAAO,MAAM,WAAW,SAAU,GAAG,oBAAoB,WAAyE,CAAC;AAEnI,eAAO,MAAM,cAAc,SAAU,GAAG,oBAAoB,SAAS,OAAO,WAK3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultCache.d.ts","sourceRoot":"","sources":["../../src/worker/defaultCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,eAAO,MAAM,YAAY,kBA0NG,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RuntimeCaching } from "@serwist/sw";
|
|
2
|
+
export interface PageRuntimeCaching extends Omit<RuntimeCaching, "options"> {
|
|
3
|
+
options?: Omit<NonNullable<RuntimeCaching["options"]>, "cacheName">;
|
|
4
|
+
}
|
|
5
|
+
export interface DefinePageRuntimeCachingOptions {
|
|
6
|
+
rscPrefetch?: PageRuntimeCaching;
|
|
7
|
+
rsc?: PageRuntimeCaching;
|
|
8
|
+
html?: PageRuntimeCaching;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Conveniently define three `runtimeCaching` entries for Next.js pages.
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare const definePageRuntimeCaching: ({ rscPrefetch, rsc, html }: DefinePageRuntimeCachingOptions) => RuntimeCaching[];
|
|
16
|
+
//# sourceMappingURL=definePageRuntimeCaching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definePageRuntimeCaching.d.ts","sourceRoot":"","sources":["../../src/worker/definePageRuntimeCaching.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IACzE,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;CACrE;AAED,MAAM,WAAW,+BAA+B;IAC9C,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,GAAG,CAAC,EAAE,kBAAkB,CAAC;IACzB,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,+BAAgC,+BAA+B,KAAG,cAAc,EAiBpH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-preview.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
6
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"src",
|
|
8
|
+
"dist"
|
|
9
9
|
],
|
|
10
10
|
"keywords": [
|
|
11
11
|
"serwist",
|
|
@@ -15,77 +15,75 @@
|
|
|
15
15
|
"web",
|
|
16
16
|
"service-worker"
|
|
17
17
|
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
},
|
|
18
21
|
"author": "Serwist's Team",
|
|
19
22
|
"license": "MIT",
|
|
20
23
|
"repository": "serwist/serwist",
|
|
21
24
|
"bugs": "https://github.com/serwist/serwist/issues",
|
|
22
25
|
"homepage": "https://serwist.pages.dev",
|
|
23
|
-
"
|
|
24
|
-
"main": "./dist/index.cjs",
|
|
26
|
+
"main": "./dist/index.js",
|
|
25
27
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"import": {
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"default": "./dist/index.js"
|
|
31
|
-
},
|
|
32
|
-
"require": {
|
|
33
|
-
"types": "./dist/index.d.cts",
|
|
34
|
-
"default": "./dist/index.cjs"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"./browser": {
|
|
38
|
-
"import": {
|
|
39
|
-
"types": "./dist/index.browser.d.ts",
|
|
40
|
-
"default": "./dist/index.browser.js"
|
|
41
|
-
},
|
|
42
|
-
"require": {
|
|
43
|
-
"types": "./dist/index.browser.d.cts",
|
|
44
|
-
"default": "./dist/index.browser.cjs"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"./typings": {
|
|
48
|
-
"import": {
|
|
49
|
-
"types": "./dist/sw-entry.d.ts"
|
|
50
|
-
},
|
|
51
|
-
"require": {
|
|
52
|
-
"types": "./dist/sw-entry.d.cts"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"./package.json": "./package.json"
|
|
56
|
-
},
|
|
57
28
|
"typesVersions": {
|
|
58
29
|
"*": {
|
|
59
|
-
"
|
|
60
|
-
"./dist/index.
|
|
30
|
+
"worker": [
|
|
31
|
+
"./dist/index.worker.d.ts"
|
|
61
32
|
],
|
|
62
33
|
"typings": [
|
|
63
34
|
"./dist/sw-entry.d.ts"
|
|
64
35
|
]
|
|
65
36
|
}
|
|
66
37
|
},
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./worker": {
|
|
44
|
+
"types": "./dist/index.worker.d.ts",
|
|
45
|
+
"default": "./dist/index.worker.js"
|
|
46
|
+
},
|
|
47
|
+
"./typings": {
|
|
48
|
+
"types": "./dist/sw-entry.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./package.json": "./package.json"
|
|
51
|
+
},
|
|
67
52
|
"dependencies": {
|
|
68
53
|
"clean-webpack-plugin": "4.0.0",
|
|
69
54
|
"fast-glob": "3.3.2",
|
|
70
|
-
"@serwist/build": "
|
|
71
|
-
"@serwist/
|
|
72
|
-
"@serwist/
|
|
55
|
+
"@serwist/build": "9.0.0-preview.0",
|
|
56
|
+
"@serwist/core": "9.0.0-preview.0",
|
|
57
|
+
"@serwist/webpack-plugin": "9.0.0-preview.0",
|
|
58
|
+
"@serwist/window": "9.0.0-preview.0"
|
|
73
59
|
},
|
|
74
60
|
"devDependencies": {
|
|
75
|
-
"@types/node": "20.
|
|
61
|
+
"@types/node": "20.11.16",
|
|
76
62
|
"chalk": "5.3.0",
|
|
77
|
-
"next": "14.0
|
|
63
|
+
"next": "14.1.0",
|
|
78
64
|
"react": "18.2.0",
|
|
79
65
|
"react-dom": "18.2.0",
|
|
80
|
-
"rollup": "4.9.
|
|
81
|
-
"type-fest": "4.
|
|
82
|
-
"typescript": "5.4.0-dev.
|
|
83
|
-
"webpack": "5.
|
|
84
|
-
"@serwist/constants": "
|
|
66
|
+
"rollup": "4.9.6",
|
|
67
|
+
"type-fest": "4.10.2",
|
|
68
|
+
"typescript": "5.4.0-dev.20240203",
|
|
69
|
+
"webpack": "5.90.1",
|
|
70
|
+
"@serwist/constants": "9.0.0-preview.0",
|
|
71
|
+
"@serwist/sw": "9.0.0-preview.0",
|
|
72
|
+
"@serwist/utils": "9.0.0-preview.0"
|
|
85
73
|
},
|
|
86
74
|
"peerDependencies": {
|
|
87
75
|
"next": ">=14.0.0",
|
|
88
|
-
"
|
|
76
|
+
"typescript": ">=5.0.0",
|
|
77
|
+
"webpack": ">=5.9.0",
|
|
78
|
+
"@serwist/sw": "9.0.0-preview.0"
|
|
79
|
+
},
|
|
80
|
+
"peerDependenciesMeta": {
|
|
81
|
+
"@serwist/sw": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"typescript": {
|
|
85
|
+
"optional": true
|
|
86
|
+
}
|
|
89
87
|
},
|
|
90
88
|
"scripts": {
|
|
91
89
|
"build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
|