@serwist/next 8.4.1 → 8.4.3
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.browser.d.cts +2 -0
- package/dist/index.cjs +23 -22
- package/dist/index.d.cts +5 -0
- package/dist/index.js +23 -22
- package/dist/internal-types.d.cts +9 -0
- package/dist/sw-entry-worker.d.cts +7 -0
- package/dist/sw-entry.d.cts +6 -0
- package/dist/types.d.cts +81 -0
- package/dist/utils/find-first-truthy.d.cts +7 -0
- package/dist/utils/get-content-hash.d.cts +3 -0
- package/dist/utils/get-file-hash.d.cts +3 -0
- package/dist/utils/get-package-version.d.cts +6 -0
- package/dist/utils/index.d.cts +6 -0
- package/dist/utils/load-tsconfig.d.cts +2 -0
- package/dist/utils/logger.d.cts +5 -0
- package/package.json +5 -5
package/dist/index.browser.d.cts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -792,29 +792,30 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
792
792
|
}));
|
|
793
793
|
const swEntryJs = path.join(__dirname$1, "sw-entry.js");
|
|
794
794
|
const entry = config.entry;
|
|
795
|
-
config.entry = ()=>
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
]
|
|
804
|
-
|
|
795
|
+
config.entry = async ()=>{
|
|
796
|
+
const entries = await entry();
|
|
797
|
+
if (entries["main.js"] && !entries["main.js"].includes(swEntryJs)) {
|
|
798
|
+
if (Array.isArray(entries["main.js"])) {
|
|
799
|
+
entries["main.js"].unshift(swEntryJs);
|
|
800
|
+
} else if (typeof entries["main.js"] === "string") {
|
|
801
|
+
entries["main.js"] = [
|
|
802
|
+
swEntryJs,
|
|
803
|
+
entries["main.js"]
|
|
804
|
+
];
|
|
805
805
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
]
|
|
814
|
-
|
|
806
|
+
}
|
|
807
|
+
if (entries["main-app"] && !entries["main-app"].includes(swEntryJs)) {
|
|
808
|
+
if (Array.isArray(entries["main-app"])) {
|
|
809
|
+
entries["main-app"].unshift(swEntryJs);
|
|
810
|
+
} else if (typeof entries["main-app"] === "string") {
|
|
811
|
+
entries["main-app"] = [
|
|
812
|
+
swEntryJs,
|
|
813
|
+
entries["main-app"]
|
|
814
|
+
];
|
|
815
815
|
}
|
|
816
|
-
|
|
817
|
-
|
|
816
|
+
}
|
|
817
|
+
return entries;
|
|
818
|
+
};
|
|
818
819
|
if (!options.isServer) {
|
|
819
820
|
if (!register) {
|
|
820
821
|
info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:");
|
|
@@ -859,7 +860,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
859
860
|
]
|
|
860
861
|
}));
|
|
861
862
|
// Precache files in public folder
|
|
862
|
-
let resolvedManifestEntries = additionalPrecacheEntries
|
|
863
|
+
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
863
864
|
if (!resolvedManifestEntries) {
|
|
864
865
|
const swDestFileName = path.basename(swDest);
|
|
865
866
|
resolvedManifestEntries = fg.sync([
|
package/dist/index.d.cts
CHANGED
package/dist/index.js
CHANGED
|
@@ -787,29 +787,30 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
787
787
|
}));
|
|
788
788
|
const swEntryJs = path.join(__dirname, "sw-entry.js");
|
|
789
789
|
const entry = config.entry;
|
|
790
|
-
config.entry = ()=>
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
]
|
|
799
|
-
|
|
790
|
+
config.entry = async ()=>{
|
|
791
|
+
const entries = await entry();
|
|
792
|
+
if (entries["main.js"] && !entries["main.js"].includes(swEntryJs)) {
|
|
793
|
+
if (Array.isArray(entries["main.js"])) {
|
|
794
|
+
entries["main.js"].unshift(swEntryJs);
|
|
795
|
+
} else if (typeof entries["main.js"] === "string") {
|
|
796
|
+
entries["main.js"] = [
|
|
797
|
+
swEntryJs,
|
|
798
|
+
entries["main.js"]
|
|
799
|
+
];
|
|
800
800
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
]
|
|
809
|
-
|
|
801
|
+
}
|
|
802
|
+
if (entries["main-app"] && !entries["main-app"].includes(swEntryJs)) {
|
|
803
|
+
if (Array.isArray(entries["main-app"])) {
|
|
804
|
+
entries["main-app"].unshift(swEntryJs);
|
|
805
|
+
} else if (typeof entries["main-app"] === "string") {
|
|
806
|
+
entries["main-app"] = [
|
|
807
|
+
swEntryJs,
|
|
808
|
+
entries["main-app"]
|
|
809
|
+
];
|
|
810
810
|
}
|
|
811
|
-
|
|
812
|
-
|
|
811
|
+
}
|
|
812
|
+
return entries;
|
|
813
|
+
};
|
|
813
814
|
if (!options.isServer) {
|
|
814
815
|
if (!register) {
|
|
815
816
|
info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:");
|
|
@@ -854,7 +855,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
854
855
|
]
|
|
855
856
|
}));
|
|
856
857
|
// Precache files in public folder
|
|
857
|
-
let resolvedManifestEntries = additionalPrecacheEntries
|
|
858
|
+
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
858
859
|
if (!resolvedManifestEntries) {
|
|
859
860
|
const swDestFileName = path.basename(swDest);
|
|
860
861
|
resolvedManifestEntries = fg.sync([
|
package/dist/sw-entry.d.cts
CHANGED
package/dist/types.d.cts
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { WebpackInjectManifestOptions } from "@serwist/build";
|
|
2
|
+
type Require<T, U extends keyof T> = T & Required<Pick<T, U>>;
|
|
3
|
+
export interface PluginOptions extends Require<WebpackInjectManifestOptions, "swDest"> {
|
|
4
|
+
/**
|
|
5
|
+
* Enable additional route caching when users navigate through pages with
|
|
6
|
+
* `next/link`. This improves the user experience in some cases but it
|
|
7
|
+
* also adds a bit of overhead due to additional network calls.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
cacheOnFrontEndNav?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether Serwist should be disabled.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
disable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether `@serwist/next` should automatically register the service worker for you. If
|
|
18
|
+
* you want to register the service worker yourself, set this to `false` and run
|
|
19
|
+
* `window.serwist.register()` in `componentDidMount` or `useEffect`.
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // app/register-pwa.tsx
|
|
23
|
+
* "use client";
|
|
24
|
+
* import { useEffect } from "react";
|
|
25
|
+
* import type { Serwist } from "@serwist/window";
|
|
26
|
+
*
|
|
27
|
+
* declare global {
|
|
28
|
+
* interface Window {
|
|
29
|
+
* serwist: Serwist;
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* export default function RegisterPWA() {
|
|
34
|
+
* useEffect(() => {
|
|
35
|
+
* if ("serviceWorker" in navigator && window.serwist !== undefined) {
|
|
36
|
+
* window.serwist.register();
|
|
37
|
+
* }
|
|
38
|
+
* }, []);
|
|
39
|
+
* return <></>;
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* // app/layout.tsx
|
|
43
|
+
* import RegisterPWA from "./register-pwa";
|
|
44
|
+
*
|
|
45
|
+
* export default function RootLayout({
|
|
46
|
+
* children,
|
|
47
|
+
* }: {
|
|
48
|
+
* children: React.ReactNode;
|
|
49
|
+
* }) {
|
|
50
|
+
* return (
|
|
51
|
+
* <html lang="en">
|
|
52
|
+
* <head />
|
|
53
|
+
* <body>
|
|
54
|
+
* <RegisterPWA />
|
|
55
|
+
* {children}
|
|
56
|
+
* </body>
|
|
57
|
+
* </html>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
register?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether Serwist should reload the app when it goes online.
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
reloadOnOnline?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The service worker's URL scope. Set to `/foo/` so that paths under `/foo/` are under the service
|
|
71
|
+
* worker's control while others are not.
|
|
72
|
+
* @default nextConfig.basePath
|
|
73
|
+
*/
|
|
74
|
+
scope?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The URL to the service worker.
|
|
77
|
+
* @default "/sw.js"
|
|
78
|
+
*/
|
|
79
|
+
swUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { findFirstTruthy } from "./find-first-truthy.js";
|
|
2
|
+
export { getContentHash } from "./get-content-hash.js";
|
|
3
|
+
export { getFileHash } from "./get-file-hash.js";
|
|
4
|
+
export { getPackageVersion } from "./get-package-version.js";
|
|
5
|
+
export { loadTSConfig } from "./load-tsconfig.js";
|
|
6
|
+
export * as logger from "./logger.js";
|
package/dist/utils/logger.d.cts
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const wait: (...message: any[]) => void;
|
|
2
|
+
export declare const error: (...message: any[]) => void;
|
|
3
|
+
export declare const warn: (...message: any[]) => void;
|
|
4
|
+
export declare const info: (...message: any[]) => void;
|
|
5
|
+
export declare const event: (...message: any[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
6
|
"files": [
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"clean-webpack-plugin": "4.0.0",
|
|
69
69
|
"fast-glob": "3.3.2",
|
|
70
|
-
"@serwist/build": "8.4.
|
|
71
|
-
"@serwist/webpack-plugin": "8.4.
|
|
72
|
-
"@serwist/window": "8.4.
|
|
70
|
+
"@serwist/build": "8.4.3",
|
|
71
|
+
"@serwist/webpack-plugin": "8.4.3",
|
|
72
|
+
"@serwist/window": "8.4.3"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/node": "20.10.5",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"type-fest": "4.8.3",
|
|
82
82
|
"typescript": "5.4.0-dev.20231226",
|
|
83
83
|
"webpack": "5.89.0",
|
|
84
|
-
"@serwist/constants": "8.4.
|
|
84
|
+
"@serwist/constants": "8.4.3"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"next": ">=14.0.0",
|