@serwist/turbopack 9.3.1 → 9.4.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.react.d.ts +7 -1
- package/dist/index.react.d.ts.map +1 -1
- package/dist/index.react.js +9 -14
- package/package.json +6 -6
- package/src/index.react.tsx +14 -8
package/dist/index.react.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ReactNode } from "react";
|
|
|
3
3
|
import { useSerwist } from "./lib/context.js";
|
|
4
4
|
export interface SerwistProviderProps {
|
|
5
5
|
swUrl: string;
|
|
6
|
+
disable?: boolean;
|
|
6
7
|
register?: boolean;
|
|
7
8
|
cacheOnNavigation?: boolean;
|
|
8
9
|
reloadOnOnline?: boolean;
|
|
@@ -14,6 +15,11 @@ declare global {
|
|
|
14
15
|
serwist: Serwist;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* `@serwist/window` provider for Next.js apps.
|
|
20
|
+
* @param options
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function SerwistProvider({ swUrl, disable, register, cacheOnNavigation, reloadOnOnline, options, children, }: SerwistProviderProps): import("react").JSX.Element;
|
|
18
24
|
export { useSerwist };
|
|
19
25
|
//# sourceMappingURL=index.react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.react.d.ts","sourceRoot":"","sources":["../src/index.react.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAED,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAe,EACf,iBAAwB,EACxB,cAAqB,EACrB,OAAO,EACP,QAAQ,GACT,EAAE,oBAAoB,+
|
|
1
|
+
{"version":3,"file":"index.react.d.ts","sourceRoot":"","sources":["../src/index.react.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,OAAe,EACf,QAAe,EACf,iBAAwB,EACxB,cAAqB,EACrB,OAAO,EACP,QAAQ,GACT,EAAE,oBAAoB,+BAuDtB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/index.react.js
CHANGED
|
@@ -12,28 +12,23 @@ const useSerwist = ()=>{
|
|
|
12
12
|
return context;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
function SerwistProvider({ swUrl, register = true, cacheOnNavigation = true, reloadOnOnline = true, options, children }) {
|
|
15
|
+
function SerwistProvider({ swUrl, disable = false, register = true, cacheOnNavigation = true, reloadOnOnline = true, options, children }) {
|
|
16
16
|
const [serwist] = useState(()=>{
|
|
17
17
|
if (typeof window === "undefined") return null;
|
|
18
|
+
if (disable) return null;
|
|
19
|
+
const scope = options?.scope || "/";
|
|
18
20
|
if (!(window.serwist && window.serwist instanceof Serwist) && "serviceWorker" in navigator) {
|
|
19
21
|
window.serwist = new Serwist(swUrl, {
|
|
20
22
|
...options,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
scope,
|
|
24
|
+
type: options?.type || "module"
|
|
23
25
|
});
|
|
26
|
+
if (register && !isCurrentPageOutOfScope(scope)) {
|
|
27
|
+
void window.serwist.register();
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
return window.serwist ?? null;
|
|
26
31
|
});
|
|
27
|
-
useEffect(()=>{
|
|
28
|
-
const scope = options?.scope || "/";
|
|
29
|
-
if (register && !isCurrentPageOutOfScope(scope)) {
|
|
30
|
-
void serwist?.register();
|
|
31
|
-
}
|
|
32
|
-
}, [
|
|
33
|
-
register,
|
|
34
|
-
options?.scope,
|
|
35
|
-
serwist?.register
|
|
36
|
-
]);
|
|
37
32
|
useEffect(()=>{
|
|
38
33
|
const cacheUrls = async (url)=>{
|
|
39
34
|
if (!window.navigator.onLine || !url) {
|
|
@@ -68,7 +63,7 @@ function SerwistProvider({ swUrl, register = true, cacheOnNavigation = true, rel
|
|
|
68
63
|
window.removeEventListener("online", cacheCurrentPathname);
|
|
69
64
|
};
|
|
70
65
|
}, [
|
|
71
|
-
serwist
|
|
66
|
+
serwist,
|
|
72
67
|
cacheOnNavigation
|
|
73
68
|
]);
|
|
74
69
|
useEffect(()=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/turbopack",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "A module that integrates Serwist into your Next.js / Turbopack application.",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"kolorist": "1.8.0",
|
|
68
68
|
"semver": "7.7.3",
|
|
69
69
|
"zod": "4.2.1",
|
|
70
|
-
"@serwist/
|
|
71
|
-
"serwist": "9.
|
|
72
|
-
"
|
|
70
|
+
"@serwist/build": "9.4.0",
|
|
71
|
+
"@serwist/window": "9.4.0",
|
|
72
|
+
"serwist": "9.4.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/node": "25.0.3",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"rollup": "4.54.0",
|
|
83
83
|
"type-fest": "5.3.1",
|
|
84
84
|
"typescript": "5.9.3",
|
|
85
|
-
"@serwist/
|
|
86
|
-
"@serwist/
|
|
85
|
+
"@serwist/utils": "9.4.0",
|
|
86
|
+
"@serwist/configs": "9.4.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"esbuild-wasm": ">=0.25.0 <1.0.0",
|
package/src/index.react.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { SerwistContext, useSerwist } from "./lib/context.js";
|
|
|
5
5
|
|
|
6
6
|
export interface SerwistProviderProps {
|
|
7
7
|
swUrl: string;
|
|
8
|
+
disable?: boolean;
|
|
8
9
|
register?: boolean;
|
|
9
10
|
cacheOnNavigation?: boolean;
|
|
10
11
|
reloadOnOnline?: boolean;
|
|
@@ -18,8 +19,14 @@ declare global {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* `@serwist/window` provider for Next.js apps.
|
|
24
|
+
* @param options
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
21
27
|
export function SerwistProvider({
|
|
22
28
|
swUrl,
|
|
29
|
+
disable = false,
|
|
23
30
|
register = true,
|
|
24
31
|
cacheOnNavigation = true,
|
|
25
32
|
reloadOnOnline = true,
|
|
@@ -28,17 +35,16 @@ export function SerwistProvider({
|
|
|
28
35
|
}: SerwistProviderProps) {
|
|
29
36
|
const [serwist] = useState(() => {
|
|
30
37
|
if (typeof window === "undefined") return null;
|
|
38
|
+
if (disable) return null;
|
|
39
|
+
const scope = options?.scope || "/";
|
|
31
40
|
if (!(window.serwist && window.serwist instanceof Serwist) && "serviceWorker" in navigator) {
|
|
32
|
-
window.serwist = new Serwist(swUrl, { ...options, type: options?.type || "module"
|
|
41
|
+
window.serwist = new Serwist(swUrl, { ...options, scope, type: options?.type || "module" });
|
|
42
|
+
if (register && !isCurrentPageOutOfScope(scope)) {
|
|
43
|
+
void window.serwist.register();
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
return window.serwist ?? null;
|
|
35
47
|
});
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const scope = options?.scope || "/";
|
|
38
|
-
if (register && !isCurrentPageOutOfScope(scope)) {
|
|
39
|
-
void serwist?.register();
|
|
40
|
-
}
|
|
41
|
-
}, [register, options?.scope, serwist?.register]);
|
|
42
48
|
useEffect(() => {
|
|
43
49
|
const cacheUrls = async (url?: string | URL | null | undefined) => {
|
|
44
50
|
if (!window.navigator.onLine || !url) {
|
|
@@ -70,7 +76,7 @@ export function SerwistProvider({
|
|
|
70
76
|
history.replaceState = replaceState;
|
|
71
77
|
window.removeEventListener("online", cacheCurrentPathname);
|
|
72
78
|
};
|
|
73
|
-
}, [serwist
|
|
79
|
+
}, [serwist, cacheOnNavigation]);
|
|
74
80
|
useEffect(() => {
|
|
75
81
|
const reload = () => location.reload();
|
|
76
82
|
if (reloadOnOnline) {
|