@serwist/build 9.0.0-preview.2 → 9.0.0-preview.21
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/chunks/glob.js +3 -3
- package/dist/chunks/injectManifest.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -58
- package/dist/index.schema.d.ts +13 -0
- package/dist/index.schema.d.ts.map +1 -0
- package/dist/index.schema.js +9 -0
- package/dist/lib/additional-precache-entries-transform.d.ts +6 -8
- package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -1
- package/dist/lib/errors.d.ts +0 -3
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/get-file-details.d.ts +3 -9
- package/dist/lib/get-file-details.d.ts.map +1 -1
- package/dist/lib/get-file-hash.d.ts +1 -1
- package/dist/lib/get-file-hash.d.ts.map +1 -1
- package/dist/lib/get-file-manifest-entries.d.ts +2 -2
- package/dist/lib/get-file-manifest-entries.d.ts.map +1 -1
- package/dist/lib/get-string-details.d.ts +1 -1
- package/dist/lib/get-string-details.d.ts.map +1 -1
- package/dist/lib/get-string-hash.d.ts +1 -1
- package/dist/lib/get-string-hash.d.ts.map +1 -1
- package/dist/lib/transform-manifest.d.ts +4 -3
- package/dist/lib/transform-manifest.d.ts.map +1 -1
- package/dist/lib/validate-options.d.ts +1 -3
- package/dist/lib/validate-options.d.ts.map +1 -1
- package/dist/schema/assertType.d.ts +1 -0
- package/dist/schema/assertType.d.ts.map +1 -1
- package/dist/schema/base.d.ts +24 -24
- package/dist/schema/getManifest.d.ts +24 -24
- package/dist/schema/injectManifest.d.ts +27 -27
- package/dist/schema/injectManifest.d.ts.map +1 -1
- package/dist/schema/manifestEntry.d.ts +3 -3
- package/dist/schema/manifestTransform.d.ts +18 -18
- package/dist/{lib/serwist-config-error.d.ts → schema/serwistConfigError.d.ts} +1 -1
- package/dist/schema/serwistConfigError.d.ts.map +1 -0
- package/dist/types.d.ts +6 -156
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -23
- package/src/index.schema.ts +29 -0
- package/src/index.ts +2 -3
- package/src/inject-manifest.ts +1 -1
- package/src/lib/additional-precache-entries-transform.ts +4 -8
- package/src/lib/errors.ts +0 -6
- package/src/lib/get-composite-details.ts +2 -2
- package/src/lib/get-file-details.ts +9 -17
- package/src/lib/get-file-hash.ts +4 -4
- package/src/lib/get-file-manifest-entries.ts +9 -9
- package/src/lib/get-string-details.ts +5 -7
- package/src/lib/get-string-hash.ts +1 -1
- package/src/lib/transform-manifest.ts +28 -16
- package/src/lib/validate-options.ts +2 -23
- package/src/schema/assertType.ts +2 -0
- package/src/schema/injectManifest.ts +4 -4
- package/src/schema/manifestEntry.ts +1 -1
- package/src/types.ts +6 -188
- package/dist/chunks/vite.js +0 -7
- package/dist/chunks/webpack.js +0 -34
- package/dist/index.next.d.ts +0 -3
- package/dist/index.next.d.ts.map +0 -1
- package/dist/index.next.js +0 -38
- package/dist/lib/serwist-config-error.d.ts.map +0 -1
- package/dist/lib/validate-next-options.d.ts +0 -3
- package/dist/lib/validate-next-options.d.ts.map +0 -1
- package/dist/schema/next.d.ts +0 -243
- package/dist/schema/next.d.ts.map +0 -1
- package/dist/schema/vite.d.ts +0 -196
- package/dist/schema/vite.d.ts.map +0 -1
- package/dist/schema/webpack.d.ts +0 -231
- package/dist/schema/webpack.d.ts.map +0 -1
- package/src/_types.js +0 -112
- package/src/index.next.ts +0 -3
- package/src/lib/validate-next-options.ts +0 -14
- package/src/schema/next.ts +0 -33
- package/src/schema/vite.ts +0 -18
- package/src/schema/webpack.ts +0 -47
- package/dist/chunks/{serwist-config-error.js → validationErrorMap.js} +7 -7
- /package/src/{lib/serwist-config-error.ts → schema/serwistConfigError.ts} +0 -0
|
@@ -2,119 +2,119 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const manifestTransformResult: z.ZodObject<{
|
|
3
3
|
manifest: z.ZodArray<z.ZodObject<{
|
|
4
4
|
integrity: z.ZodOptional<z.ZodString>;
|
|
5
|
-
revision: z.ZodNullable<z.ZodString
|
|
5
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
6
|
url: z.ZodString;
|
|
7
7
|
size: z.ZodNumber;
|
|
8
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
revision: string | null;
|
|
10
9
|
url: string;
|
|
11
10
|
size: number;
|
|
12
11
|
integrity?: string | undefined;
|
|
12
|
+
revision?: string | null | undefined;
|
|
13
13
|
}, {
|
|
14
|
-
revision: string | null;
|
|
15
14
|
url: string;
|
|
16
15
|
size: number;
|
|
17
16
|
integrity?: string | undefined;
|
|
17
|
+
revision?: string | null | undefined;
|
|
18
18
|
}>, "many">;
|
|
19
19
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
20
|
}, "strict", z.ZodTypeAny, {
|
|
21
21
|
manifest: {
|
|
22
|
-
revision: string | null;
|
|
23
22
|
url: string;
|
|
24
23
|
size: number;
|
|
25
24
|
integrity?: string | undefined;
|
|
25
|
+
revision?: string | null | undefined;
|
|
26
26
|
}[];
|
|
27
27
|
warnings?: string[] | undefined;
|
|
28
28
|
}, {
|
|
29
29
|
manifest: {
|
|
30
|
-
revision: string | null;
|
|
31
30
|
url: string;
|
|
32
31
|
size: number;
|
|
33
32
|
integrity?: string | undefined;
|
|
33
|
+
revision?: string | null | undefined;
|
|
34
34
|
}[];
|
|
35
35
|
warnings?: string[] | undefined;
|
|
36
36
|
}>;
|
|
37
37
|
export declare const manifestTransform: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
38
38
|
integrity: z.ZodOptional<z.ZodString>;
|
|
39
|
-
revision: z.ZodNullable<z.ZodString
|
|
39
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
40
|
url: z.ZodString;
|
|
41
41
|
size: z.ZodNumber;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
revision: string | null;
|
|
44
43
|
url: string;
|
|
45
44
|
size: number;
|
|
46
45
|
integrity?: string | undefined;
|
|
46
|
+
revision?: string | null | undefined;
|
|
47
47
|
}, {
|
|
48
|
-
revision: string | null;
|
|
49
48
|
url: string;
|
|
50
49
|
size: number;
|
|
51
50
|
integrity?: string | undefined;
|
|
51
|
+
revision?: string | null | undefined;
|
|
52
52
|
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
|
|
53
53
|
manifest: z.ZodArray<z.ZodObject<{
|
|
54
54
|
integrity: z.ZodOptional<z.ZodString>;
|
|
55
|
-
revision: z.ZodNullable<z.ZodString
|
|
55
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
56
|
url: z.ZodString;
|
|
57
57
|
size: z.ZodNumber;
|
|
58
58
|
}, "strip", z.ZodTypeAny, {
|
|
59
|
-
revision: string | null;
|
|
60
59
|
url: string;
|
|
61
60
|
size: number;
|
|
62
61
|
integrity?: string | undefined;
|
|
62
|
+
revision?: string | null | undefined;
|
|
63
63
|
}, {
|
|
64
|
-
revision: string | null;
|
|
65
64
|
url: string;
|
|
66
65
|
size: number;
|
|
67
66
|
integrity?: string | undefined;
|
|
67
|
+
revision?: string | null | undefined;
|
|
68
68
|
}>, "many">;
|
|
69
69
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
70
70
|
}, "strict", z.ZodTypeAny, {
|
|
71
71
|
manifest: {
|
|
72
|
-
revision: string | null;
|
|
73
72
|
url: string;
|
|
74
73
|
size: number;
|
|
75
74
|
integrity?: string | undefined;
|
|
75
|
+
revision?: string | null | undefined;
|
|
76
76
|
}[];
|
|
77
77
|
warnings?: string[] | undefined;
|
|
78
78
|
}, {
|
|
79
79
|
manifest: {
|
|
80
|
-
revision: string | null;
|
|
81
80
|
url: string;
|
|
82
81
|
size: number;
|
|
83
82
|
integrity?: string | undefined;
|
|
83
|
+
revision?: string | null | undefined;
|
|
84
84
|
}[];
|
|
85
85
|
warnings?: string[] | undefined;
|
|
86
86
|
}>>, z.ZodObject<{
|
|
87
87
|
manifest: z.ZodArray<z.ZodObject<{
|
|
88
88
|
integrity: z.ZodOptional<z.ZodString>;
|
|
89
|
-
revision: z.ZodNullable<z.ZodString
|
|
89
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
90
|
url: z.ZodString;
|
|
91
91
|
size: z.ZodNumber;
|
|
92
92
|
}, "strip", z.ZodTypeAny, {
|
|
93
|
-
revision: string | null;
|
|
94
93
|
url: string;
|
|
95
94
|
size: number;
|
|
96
95
|
integrity?: string | undefined;
|
|
96
|
+
revision?: string | null | undefined;
|
|
97
97
|
}, {
|
|
98
|
-
revision: string | null;
|
|
99
98
|
url: string;
|
|
100
99
|
size: number;
|
|
101
100
|
integrity?: string | undefined;
|
|
101
|
+
revision?: string | null | undefined;
|
|
102
102
|
}>, "many">;
|
|
103
103
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
104
104
|
}, "strict", z.ZodTypeAny, {
|
|
105
105
|
manifest: {
|
|
106
|
-
revision: string | null;
|
|
107
106
|
url: string;
|
|
108
107
|
size: number;
|
|
109
108
|
integrity?: string | undefined;
|
|
109
|
+
revision?: string | null | undefined;
|
|
110
110
|
}[];
|
|
111
111
|
warnings?: string[] | undefined;
|
|
112
112
|
}, {
|
|
113
113
|
manifest: {
|
|
114
|
-
revision: string | null;
|
|
115
114
|
url: string;
|
|
116
115
|
size: number;
|
|
117
116
|
integrity?: string | undefined;
|
|
117
|
+
revision?: string | null | undefined;
|
|
118
118
|
}[];
|
|
119
119
|
warnings?: string[] | undefined;
|
|
120
120
|
}>]>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serwistConfigError.d.ts","sourceRoot":"","sources":["../../src/schema/serwistConfigError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAI/E"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Require } from "@serwist/utils";
|
|
2
|
-
import type { Pattern as GlobPattern } from "fast-glob";
|
|
3
2
|
import type { PackageJson } from "type-fest";
|
|
4
3
|
import type { z } from "zod";
|
|
5
4
|
import type { manifestEntry } from "./schema/manifestEntry.js";
|
|
@@ -85,14 +84,14 @@ export interface GlobPartial {
|
|
|
85
84
|
/**
|
|
86
85
|
* Determines whether or not symlinks are followed when generating the
|
|
87
86
|
* precache manifest. For more information, see the definition of `follow` in
|
|
88
|
-
* [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
87
|
+
* [`node-glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
89
88
|
* @default true
|
|
90
89
|
*/
|
|
91
90
|
globFollow?: boolean;
|
|
92
91
|
/**
|
|
93
92
|
* A set of patterns matching files to always exclude when generating the
|
|
94
93
|
* precache manifest. For more information, see the definition of `ignore` in
|
|
95
|
-
* [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
94
|
+
* [`node-glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
96
95
|
* @default
|
|
97
96
|
* ```
|
|
98
97
|
* ["**\/node_modules\/**\/*"]
|
|
@@ -102,7 +101,7 @@ export interface GlobPartial {
|
|
|
102
101
|
/**
|
|
103
102
|
* Files matching any of these patterns will be included in the precache
|
|
104
103
|
* manifest. For more information, see
|
|
105
|
-
* [`glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
|
|
104
|
+
* [`node-glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
|
|
106
105
|
* @default
|
|
107
106
|
* ```
|
|
108
107
|
* ["**\/*.{js,css,html}"]
|
|
@@ -113,7 +112,7 @@ export interface GlobPartial {
|
|
|
113
112
|
* If true, an error reading a directory when generating a precache manifest
|
|
114
113
|
* will cause the build to fail. If false, the problematic directory will be
|
|
115
114
|
* skipped. For more information, see the definition of `strict` in
|
|
116
|
-
* [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
115
|
+
* [`node-glob`'s documentation](https://github.com/isaacs/node-glob#options).
|
|
117
116
|
* @default true
|
|
118
117
|
*/
|
|
119
118
|
globStrict?: boolean;
|
|
@@ -121,7 +120,7 @@ export interface GlobPartial {
|
|
|
121
120
|
* If a URL is rendered based on some server-side logic, its contents may
|
|
122
121
|
* depend on multiple files or on some other unique string value. The keys in
|
|
123
122
|
* this object are server-rendered URLs. If the values are an array of
|
|
124
|
-
* strings, they will be interpreted as
|
|
123
|
+
* strings, they will be interpreted as glob patterns, and the contents of
|
|
125
124
|
* any files matching the patterns will be used to uniquely version the URL.
|
|
126
125
|
* If used with a single string, it will be interpreted as unique versioning
|
|
127
126
|
* information that you've generated for a given URL.
|
|
@@ -145,44 +144,6 @@ export interface InjectPartial {
|
|
|
145
144
|
swSrc: string;
|
|
146
145
|
}
|
|
147
146
|
export type InjectResolved = Require<InjectPartial, "injectionPoint">;
|
|
148
|
-
export interface WebpackPartial {
|
|
149
|
-
/**
|
|
150
|
-
* One or more chunk names whose corresponding output files should be included
|
|
151
|
-
* in the precache manifest.
|
|
152
|
-
*/
|
|
153
|
-
chunks?: string[];
|
|
154
|
-
/**
|
|
155
|
-
* One or more specifiers used to exclude assets from the precache manifest.
|
|
156
|
-
* This is interpreted following
|
|
157
|
-
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
158
|
-
* as `webpack`'s standard `exclude` option.
|
|
159
|
-
* @default
|
|
160
|
-
* ```
|
|
161
|
-
* [/\.map$/, /^manifest.*\.js$]
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
exclude?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
165
|
-
/**
|
|
166
|
-
* One or more chunk names whose corresponding output files should be excluded
|
|
167
|
-
* from the precache manifest.
|
|
168
|
-
*/
|
|
169
|
-
excludeChunks?: string[];
|
|
170
|
-
/**
|
|
171
|
-
* One or more specifiers used to include assets in the precache manifest.
|
|
172
|
-
* This is interpreted following
|
|
173
|
-
* [the same rules](https://webpack.js.org/configuration/module/#condition)
|
|
174
|
-
* as `webpack`'s standard `include` option.
|
|
175
|
-
*/
|
|
176
|
-
include?: (string | RegExp | ((arg0: any) => boolean))[];
|
|
177
|
-
/**
|
|
178
|
-
* If set to 'production', then an optimized service worker bundle that
|
|
179
|
-
* excludes debugging info will be produced. If not explicitly configured
|
|
180
|
-
* here, the `mode` value configured in the current `webpack` compilation
|
|
181
|
-
* will be used.
|
|
182
|
-
*/
|
|
183
|
-
mode?: string | null;
|
|
184
|
-
}
|
|
185
|
-
export type WebpackResolved = Require<WebpackPartial, "exclude">;
|
|
186
147
|
export interface RequiredSwDestPartial {
|
|
187
148
|
/**
|
|
188
149
|
* The path and filename of the service worker file that will be created by
|
|
@@ -200,121 +161,10 @@ export interface OptionalSwDestPartial {
|
|
|
200
161
|
swDest?: string;
|
|
201
162
|
}
|
|
202
163
|
export type OptionalSwDestResolved = OptionalSwDestPartial;
|
|
203
|
-
export interface WebpackInjectManifestPartial {
|
|
204
|
-
/**
|
|
205
|
-
* When `true` (the default), the `swSrc` file will be compiled by `webpack`.
|
|
206
|
-
* When `false`, compilation will not occur (and `webpackCompilationPlugins`
|
|
207
|
-
* can't be used.) Set to `false` if you want to inject the manifest into,
|
|
208
|
-
* e.g., a JSON file.
|
|
209
|
-
* @default true
|
|
210
|
-
*/
|
|
211
|
-
compileSrc?: boolean;
|
|
212
|
-
/**
|
|
213
|
-
* Optional `webpack` plugins that will be used when compiling the `swSrc`
|
|
214
|
-
* input file. Only valid if `compileSrc` is `true`.
|
|
215
|
-
*/
|
|
216
|
-
webpackCompilationPlugins?: any[];
|
|
217
|
-
}
|
|
218
|
-
export type WebpackInjectManifestResolved = Require<WebpackInjectManifestPartial, "compileSrc">;
|
|
219
|
-
export interface NextInjectManifestPartial {
|
|
220
|
-
/**
|
|
221
|
-
* Enables additional route caching when users navigate through pages with
|
|
222
|
-
* `next/link`. This improves the user experience in some cases but it
|
|
223
|
-
* also adds a bit of overhead due to additional network calls.
|
|
224
|
-
* @default false
|
|
225
|
-
*/
|
|
226
|
-
cacheOnNavigation?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Whether Serwist should be disabled.
|
|
229
|
-
* @default false
|
|
230
|
-
*/
|
|
231
|
-
disable?: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Whether `@serwist/next` should automatically register the service worker for you. If
|
|
234
|
-
* you want to register the service worker yourself, set this to `false` and run
|
|
235
|
-
* `window.serwist.register()` in `componentDidMount` or `useEffect`.
|
|
236
|
-
* @example
|
|
237
|
-
* ```tsx
|
|
238
|
-
* // app/register-pwa.tsx
|
|
239
|
-
* "use client";
|
|
240
|
-
* import { useEffect } from "react";
|
|
241
|
-
* import type { Serwist } from "@serwist/window";
|
|
242
|
-
*
|
|
243
|
-
* declare global {
|
|
244
|
-
* interface Window {
|
|
245
|
-
* serwist: Serwist;
|
|
246
|
-
* }
|
|
247
|
-
* }
|
|
248
|
-
*
|
|
249
|
-
* export default function RegisterPWA() {
|
|
250
|
-
* useEffect(() => {
|
|
251
|
-
* if ("serviceWorker" in navigator && window.serwist !== undefined) {
|
|
252
|
-
* window.serwist.register();
|
|
253
|
-
* }
|
|
254
|
-
* }, []);
|
|
255
|
-
* return <></>;
|
|
256
|
-
* }
|
|
257
|
-
*
|
|
258
|
-
* // app/layout.tsx
|
|
259
|
-
* import RegisterPWA from "./register-pwa";
|
|
260
|
-
*
|
|
261
|
-
* export default function RootLayout({
|
|
262
|
-
* children,
|
|
263
|
-
* }: {
|
|
264
|
-
* children: React.ReactNode;
|
|
265
|
-
* }) {
|
|
266
|
-
* return (
|
|
267
|
-
* <html lang="en">
|
|
268
|
-
* <head />
|
|
269
|
-
* <body>
|
|
270
|
-
* <RegisterPWA />
|
|
271
|
-
* {children}
|
|
272
|
-
* </body>
|
|
273
|
-
* </html>
|
|
274
|
-
* );
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
* @default true
|
|
278
|
-
*/
|
|
279
|
-
register?: boolean;
|
|
280
|
-
/**
|
|
281
|
-
* Whether Serwist should reload the app when it goes online.
|
|
282
|
-
* @default true
|
|
283
|
-
*/
|
|
284
|
-
reloadOnOnline?: boolean;
|
|
285
|
-
/**
|
|
286
|
-
* The service worker's URL scope. Set to `/foo/` so that paths under `/foo/` are under the service
|
|
287
|
-
* worker's control while others are not.
|
|
288
|
-
* @default nextConfig.basePath
|
|
289
|
-
*/
|
|
290
|
-
scope?: string;
|
|
291
|
-
/**
|
|
292
|
-
* The URL to the service worker.
|
|
293
|
-
* @default "/sw.js"
|
|
294
|
-
*/
|
|
295
|
-
swUrl?: string;
|
|
296
|
-
/**
|
|
297
|
-
* Files in the public directory matching any of these patterns
|
|
298
|
-
* will be included in the precache manifest. For more information,
|
|
299
|
-
* see [`fast-glob`'s documentation](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax).
|
|
300
|
-
* @default
|
|
301
|
-
* ```
|
|
302
|
-
* ["**\/*"]
|
|
303
|
-
* ```
|
|
304
|
-
*/
|
|
305
|
-
globPublicPatterns?: GlobPattern | GlobPattern[];
|
|
306
|
-
}
|
|
307
|
-
export type NextInjectManifestResolved = Require<NextInjectManifestPartial, "cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">;
|
|
308
164
|
export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;
|
|
309
165
|
export type GetManifestOptionsComplete = BaseResolved & GlobResolved & RequiredGlobDirectoryResolved;
|
|
310
166
|
export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
|
|
311
167
|
export type InjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
|
|
312
|
-
export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & OptionalSwDestPartial & WebpackInjectManifestPartial;
|
|
313
|
-
export type WebpackInjectManifestOptionsComplete = BaseResolved & WebpackResolved & InjectResolved & OptionalSwDestResolved & WebpackInjectManifestResolved;
|
|
314
|
-
export type ViteInjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
|
|
315
|
-
export type ViteInjectManifestOptionsComplete = BaseResolved & GlobResolved & InjectResolved & RequiredSwDestResolved & RequiredGlobDirectoryResolved;
|
|
316
|
-
export type NextInjectManifestOptions = Omit<WebpackInjectManifestOptions & RequiredSwDestPartial & NextInjectManifestPartial, "disablePrecacheManifest">;
|
|
317
|
-
export type NextInjectManifestOptionsComplete = Omit<WebpackInjectManifestOptionsComplete & RequiredSwDestResolved & NextInjectManifestResolved, "disablePrecacheManifest">;
|
|
318
168
|
export interface GetManifestResult {
|
|
319
169
|
count: number;
|
|
320
170
|
manifestEntries: ManifestEntry[] | undefined;
|
|
@@ -329,7 +179,7 @@ export type BuildResult = Omit<GetManifestResult, "manifestEntries"> & {
|
|
|
329
179
|
*/
|
|
330
180
|
export interface FileDetails {
|
|
331
181
|
file: string;
|
|
332
|
-
hash: string;
|
|
182
|
+
hash: string | null;
|
|
333
183
|
size: number;
|
|
334
184
|
}
|
|
335
185
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EA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AA6B,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,GAAG,sBAAsB,GAAG,6BAA6B,CAAC;AAElJ,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG;IACrE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,gBAAgB,GAAG,uBAAuB,GAAG,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/build",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.",
|
|
6
6
|
"files": [
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
},
|
|
22
22
|
"author": "Google's Web DevRel Team, Serwist's Team",
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"repository": "serwist/serwist",
|
|
25
|
-
"bugs": "https://
|
|
24
|
+
"repository": "https://gitlab.com/serwist/serwist",
|
|
25
|
+
"bugs": "https://gitlab.com/serwist/serwist/issues",
|
|
26
26
|
"homepage": "https://serwist.pages.dev",
|
|
27
27
|
"main": "./dist/index.js",
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"typesVersions": {
|
|
30
30
|
"*": {
|
|
31
|
-
"
|
|
32
|
-
"./dist/index.
|
|
31
|
+
"schema": [
|
|
32
|
+
"./dist/index.schema.d.ts"
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -38,41 +38,33 @@
|
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"default": "./dist/index.js"
|
|
40
40
|
},
|
|
41
|
-
"./
|
|
42
|
-
"types": "./dist/index.
|
|
43
|
-
"default": "./dist/index.
|
|
41
|
+
"./schema": {
|
|
42
|
+
"types": "./dist/index.schema.d.ts",
|
|
43
|
+
"default": "./dist/index.schema.js"
|
|
44
44
|
},
|
|
45
45
|
"./package.json": "./package.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"common-tags": "1.8.2",
|
|
49
|
-
"fast-glob": "3.3.2",
|
|
50
49
|
"fast-json-stable-stringify": "2.1.0",
|
|
51
50
|
"fs-extra": "11.2.0",
|
|
52
51
|
"glob": "10.3.10",
|
|
53
52
|
"pretty-bytes": "6.1.1",
|
|
54
|
-
"rollup": "4.
|
|
53
|
+
"rollup": "4.13.0",
|
|
55
54
|
"source-map": "0.8.0-beta.0",
|
|
56
55
|
"upath": "2.0.1",
|
|
57
56
|
"zod": "3.22.4",
|
|
58
|
-
"@serwist/
|
|
59
|
-
"@serwist/broadcast-update": "9.0.0-preview.2",
|
|
60
|
-
"@serwist/cacheable-response": "9.0.0-preview.2",
|
|
61
|
-
"@serwist/core": "9.0.0-preview.2",
|
|
62
|
-
"@serwist/expiration": "9.0.0-preview.2",
|
|
63
|
-
"@serwist/google-analytics": "9.0.0-preview.2",
|
|
64
|
-
"@serwist/precaching": "9.0.0-preview.2",
|
|
65
|
-
"@serwist/routing": "9.0.0-preview.2"
|
|
57
|
+
"@serwist/core": "9.0.0-preview.21"
|
|
66
58
|
},
|
|
67
59
|
"devDependencies": {
|
|
68
60
|
"@types/common-tags": "1.8.4",
|
|
69
61
|
"@types/fs-extra": "11.0.4",
|
|
70
|
-
"@types/node": "20.11.
|
|
62
|
+
"@types/node": "20.11.30",
|
|
71
63
|
"@types/stringify-object": "4.0.5",
|
|
72
|
-
"type-fest": "4.
|
|
73
|
-
"typescript": "5.
|
|
74
|
-
"@serwist/constants": "9.0.0-preview.
|
|
75
|
-
"@serwist/utils": "9.0.0-preview.
|
|
64
|
+
"type-fest": "4.13.1",
|
|
65
|
+
"typescript": "5.5.0-dev.20240323",
|
|
66
|
+
"@serwist/constants": "9.0.0-preview.21",
|
|
67
|
+
"@serwist/utils": "9.0.0-preview.21"
|
|
76
68
|
},
|
|
77
69
|
"peerDependencies": {
|
|
78
70
|
"typescript": ">=5.0.0"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Assignable, type Equals, assertType } from "./schema/assertType.js";
|
|
2
|
+
import { basePartial } from "./schema/base.js";
|
|
3
|
+
import { getManifestOptions } from "./schema/getManifest.js";
|
|
4
|
+
import { globPartial, optionalGlobDirectoryPartial, requiredGlobDirectoryPartial } from "./schema/glob.js";
|
|
5
|
+
import { baseInjectPartial, injectManifestOptions } from "./schema/injectManifest.js";
|
|
6
|
+
import { manifestEntry } from "./schema/manifestEntry.js";
|
|
7
|
+
import { manifestTransform, manifestTransformResult } from "./schema/manifestTransform.js";
|
|
8
|
+
import { SerwistConfigError } from "./schema/serwistConfigError.js";
|
|
9
|
+
import { optionalSwDestPartial, requiredSwDestPartial } from "./schema/swDest.js";
|
|
10
|
+
import { validationErrorMap } from "./schema/validationErrorMap.js";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
assertType,
|
|
14
|
+
basePartial,
|
|
15
|
+
globPartial,
|
|
16
|
+
baseInjectPartial as injectPartial,
|
|
17
|
+
injectManifestOptions,
|
|
18
|
+
getManifestOptions,
|
|
19
|
+
manifestEntry,
|
|
20
|
+
manifestTransform,
|
|
21
|
+
manifestTransformResult,
|
|
22
|
+
optionalGlobDirectoryPartial,
|
|
23
|
+
requiredGlobDirectoryPartial,
|
|
24
|
+
optionalSwDestPartial,
|
|
25
|
+
requiredSwDestPartial,
|
|
26
|
+
validationErrorMap,
|
|
27
|
+
SerwistConfigError,
|
|
28
|
+
};
|
|
29
|
+
export type { Assignable, Equals };
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { rebasePath } from "./lib/rebase-path.js";
|
|
|
17
17
|
import { replaceAndUpdateSourceMap } from "./lib/replace-and-update-source-map.js";
|
|
18
18
|
import { transformManifest } from "./lib/transform-manifest.js";
|
|
19
19
|
import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
|
|
20
|
-
import {
|
|
20
|
+
import { validateGetManifestOptions, validateInjectManifestOptions } from "./lib/validate-options.js";
|
|
21
21
|
|
|
22
22
|
export {
|
|
23
23
|
errors,
|
|
@@ -31,9 +31,8 @@ export {
|
|
|
31
31
|
stringify,
|
|
32
32
|
transformManifest,
|
|
33
33
|
translateURLToSourcemapPaths,
|
|
34
|
+
validateGetManifestOptions,
|
|
34
35
|
validateInjectManifestOptions,
|
|
35
|
-
validateViteInjectManifestOptions,
|
|
36
|
-
validateWebpackInjectManifestOptions,
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
export type * from "./types.js";
|
package/src/inject-manifest.ts
CHANGED
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
import type { ManifestEntry } from "../types.js";
|
|
10
10
|
import { errors } from "./errors.js";
|
|
11
11
|
|
|
12
|
-
type AdditionalManifestEntriesTransform = {
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
): {
|
|
16
|
-
manifest: (ManifestEntry & { size: number })[];
|
|
17
|
-
warnings: string[];
|
|
18
|
-
};
|
|
12
|
+
type AdditionalManifestEntriesTransform = (manifest: (ManifestEntry & { size: number })[]) => {
|
|
13
|
+
manifest: (ManifestEntry & { size: number })[];
|
|
14
|
+
warnings: string[];
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
export const additionalPrecacheEntriesTransform = (additionalPrecacheEntries: (ManifestEntry | string)[]): AdditionalManifestEntriesTransform => {
|
|
@@ -34,7 +30,7 @@ export const additionalPrecacheEntriesTransform = (additionalPrecacheEntries: (M
|
|
|
34
30
|
url: additionalEntry,
|
|
35
31
|
});
|
|
36
32
|
} else {
|
|
37
|
-
if (additionalEntry && additionalEntry.revision === undefined) {
|
|
33
|
+
if (additionalEntry && !additionalEntry.integrity && additionalEntry.revision === undefined) {
|
|
38
34
|
stringEntries.add(additionalEntry.url);
|
|
39
35
|
}
|
|
40
36
|
manifest.push(Object.assign({ size: 0 }, additionalEntry));
|
package/src/lib/errors.ts
CHANGED
|
@@ -72,12 +72,6 @@ export const errors = {
|
|
|
72
72
|
Please remove or fix the following: `,
|
|
73
73
|
"bad-template-urls-asset": ol`There was an issue using one of the provided
|
|
74
74
|
'templatedURLs'.`,
|
|
75
|
-
"invalid-runtime-caching": ol`The 'runtimeCaching' parameter must an an
|
|
76
|
-
array of objects with at least a 'urlPattern' and 'handler'.`,
|
|
77
|
-
"urlPattern-is-required": ol`The 'urlPattern' option is required when using
|
|
78
|
-
'runtimeCaching'.`,
|
|
79
|
-
"handler-is-required": ol`The 'handler' option is required when using
|
|
80
|
-
runtimeCaching.`,
|
|
81
75
|
"invalid-generate-file-manifest-arg": ol`The input to generateFileManifest()
|
|
82
76
|
must be an Object.`,
|
|
83
77
|
"invalid-sw-src": `The 'swSrc' file can't be read.`,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import crypto from "crypto";
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
10
|
|
|
11
11
|
import type { FileDetails } from "../types.js";
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ export const getCompositeDetails = (compositeURL: string, dependencyDetails: Fil
|
|
|
16
16
|
|
|
17
17
|
for (const fileDetails of dependencyDetails) {
|
|
18
18
|
totalSize += fileDetails.size;
|
|
19
|
-
compositeHash += fileDetails.hash;
|
|
19
|
+
compositeHash += fileDetails.hash === null ? "" : fileDetails.hash;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const md5 = crypto.createHash("md5");
|
|
@@ -5,22 +5,14 @@
|
|
|
5
5
|
license that can be found in the LICENSE file or at
|
|
6
6
|
https://opensource.org/licenses/MIT.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import type { GlobPartial } from "../types.js";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { globSync } from "glob";
|
|
10
|
+
import type { FileDetails, GlobPartial } from "../types.js";
|
|
13
11
|
import { errors } from "./errors.js";
|
|
14
12
|
import { getFileHash } from "./get-file-hash.js";
|
|
15
13
|
import { getFileSize } from "./get-file-size.js";
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
file: string;
|
|
19
|
-
hash: string;
|
|
20
|
-
size: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getFileDetails({
|
|
15
|
+
export const getFileDetails = ({
|
|
24
16
|
globDirectory,
|
|
25
17
|
globFollow,
|
|
26
18
|
globIgnores,
|
|
@@ -32,12 +24,12 @@ export function getFileDetails({
|
|
|
32
24
|
}): {
|
|
33
25
|
globbedFileDetails: FileDetails[];
|
|
34
26
|
warning: string;
|
|
35
|
-
} {
|
|
27
|
+
} => {
|
|
36
28
|
let globbedFiles: string[];
|
|
37
29
|
let warning = "";
|
|
38
30
|
|
|
39
31
|
try {
|
|
40
|
-
globbedFiles =
|
|
32
|
+
globbedFiles = globSync(globPattern, {
|
|
41
33
|
cwd: globDirectory,
|
|
42
34
|
follow: globFollow,
|
|
43
35
|
ignore: globIgnores,
|
|
@@ -52,12 +44,12 @@ export function getFileDetails({
|
|
|
52
44
|
|
|
53
45
|
const globbedFileDetails: FileDetails[] = [];
|
|
54
46
|
for (const file of globbedFiles) {
|
|
55
|
-
const fullPath =
|
|
47
|
+
const fullPath = path.join(globDirectory, file);
|
|
56
48
|
const fileSize = getFileSize(fullPath);
|
|
57
49
|
if (fileSize !== null) {
|
|
58
50
|
const fileHash = getFileHash(fullPath);
|
|
59
51
|
globbedFileDetails.push({
|
|
60
|
-
file:
|
|
52
|
+
file: path.relative(globDirectory, fullPath),
|
|
61
53
|
hash: fileHash,
|
|
62
54
|
size: fileSize,
|
|
63
55
|
});
|
|
@@ -65,4 +57,4 @@ export function getFileDetails({
|
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
return { globbedFileDetails, warning };
|
|
68
|
-
}
|
|
60
|
+
};
|