@serwist/build 8.4.3 → 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.
Files changed (125) hide show
  1. package/dist/chunks/getManifest.js +6 -0
  2. package/dist/chunks/glob.js +60 -0
  3. package/dist/chunks/injectManifest.js +23 -0
  4. package/dist/chunks/serwist-config-error.js +57 -0
  5. package/dist/chunks/vite.js +7 -0
  6. package/dist/chunks/webpack.js +34 -0
  7. package/dist/get-manifest.d.ts +2 -1
  8. package/dist/get-manifest.d.ts.map +1 -0
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +53 -813
  12. package/dist/index.next.d.ts +3 -0
  13. package/dist/index.next.d.ts.map +1 -0
  14. package/dist/index.next.js +35 -0
  15. package/dist/inject-manifest.d.ts +2 -1
  16. package/dist/inject-manifest.d.ts.map +1 -0
  17. package/dist/lib/additional-precache-entries-transform.d.ts +6 -5
  18. package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -0
  19. package/dist/lib/errors.d.ts +1 -2
  20. package/dist/lib/errors.d.ts.map +1 -0
  21. package/dist/lib/escape-regexp.d.ts +2 -1
  22. package/dist/lib/escape-regexp.d.ts.map +1 -0
  23. package/dist/lib/get-composite-details.d.ts +2 -1
  24. package/dist/lib/get-composite-details.d.ts.map +1 -0
  25. package/dist/lib/get-file-details.d.ts +2 -1
  26. package/dist/lib/get-file-details.d.ts.map +1 -0
  27. package/dist/lib/get-file-hash.d.ts +1 -0
  28. package/dist/lib/get-file-hash.d.ts.map +1 -0
  29. package/dist/lib/get-file-manifest-entries.d.ts +1 -0
  30. package/dist/lib/get-file-manifest-entries.d.ts.map +1 -0
  31. package/dist/lib/get-file-size.d.ts +1 -0
  32. package/dist/lib/get-file-size.d.ts.map +1 -0
  33. package/dist/lib/get-source-map-url.d.ts +1 -0
  34. package/dist/lib/get-source-map-url.d.ts.map +1 -0
  35. package/dist/lib/get-string-details.d.ts +1 -0
  36. package/dist/lib/get-string-details.d.ts.map +1 -0
  37. package/dist/lib/get-string-hash.d.ts +1 -0
  38. package/dist/lib/get-string-hash.d.ts.map +1 -0
  39. package/dist/lib/maximum-size-transform.d.ts +1 -0
  40. package/dist/lib/maximum-size-transform.d.ts.map +1 -0
  41. package/dist/lib/modify-url-prefix-transform.d.ts +1 -0
  42. package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -0
  43. package/dist/lib/no-revision-for-urls-matching-transform.d.ts +1 -0
  44. package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -0
  45. package/dist/lib/rebase-path.d.ts +1 -0
  46. package/dist/lib/rebase-path.d.ts.map +1 -0
  47. package/dist/lib/replace-and-update-source-map.d.ts +1 -0
  48. package/dist/lib/replace-and-update-source-map.d.ts.map +1 -0
  49. package/dist/lib/serwist-config-error.d.ts +7 -0
  50. package/dist/lib/serwist-config-error.d.ts.map +1 -0
  51. package/dist/lib/transform-manifest.d.ts +2 -1
  52. package/dist/lib/transform-manifest.d.ts.map +1 -0
  53. package/dist/lib/translate-url-to-sourcemap-paths.d.ts +1 -0
  54. package/dist/lib/translate-url-to-sourcemap-paths.d.ts.map +1 -0
  55. package/dist/lib/validate-next-options.d.ts +3 -0
  56. package/dist/lib/validate-next-options.d.ts.map +1 -0
  57. package/dist/lib/validate-options.d.ts +6 -8
  58. package/dist/lib/validate-options.d.ts.map +1 -0
  59. package/dist/schema/base.d.ts +169 -0
  60. package/dist/schema/base.d.ts.map +1 -0
  61. package/dist/schema/getManifest.d.ts +187 -0
  62. package/dist/schema/getManifest.d.ts.map +1 -0
  63. package/dist/schema/glob.d.ts +35 -0
  64. package/dist/schema/glob.d.ts.map +1 -0
  65. package/dist/schema/injectManifest.d.ts +206 -0
  66. package/dist/schema/injectManifest.d.ts.map +1 -0
  67. package/dist/schema/manifestEntry.d.ts +15 -0
  68. package/dist/schema/manifestEntry.d.ts.map +1 -0
  69. package/dist/schema/manifestTransform.d.ts +121 -0
  70. package/dist/schema/manifestTransform.d.ts.map +1 -0
  71. package/dist/schema/next.d.ts +243 -0
  72. package/dist/schema/next.d.ts.map +1 -0
  73. package/dist/schema/swDest.d.ts +16 -0
  74. package/dist/schema/swDest.d.ts.map +1 -0
  75. package/dist/schema/validationErrorMap.d.ts +3 -0
  76. package/dist/schema/validationErrorMap.d.ts.map +1 -0
  77. package/dist/schema/vite.d.ts +196 -0
  78. package/dist/schema/vite.d.ts.map +1 -0
  79. package/dist/schema/webpack.d.ts +231 -0
  80. package/dist/schema/webpack.d.ts.map +1 -0
  81. package/dist/types.d.ts +147 -175
  82. package/dist/types.d.ts.map +1 -0
  83. package/package.json +42 -28
  84. package/src/_types.js +112 -0
  85. package/src/get-manifest.ts +33 -0
  86. package/src/index.next.ts +3 -0
  87. package/{dist/index.d.cts → src/index.ts} +27 -2
  88. package/src/inject-manifest.ts +140 -0
  89. package/src/lib/additional-precache-entries-transform.ts +58 -0
  90. package/src/lib/errors.ts +99 -0
  91. package/src/lib/escape-regexp.ts +12 -0
  92. package/src/lib/get-composite-details.ts +31 -0
  93. package/src/lib/get-file-details.ts +68 -0
  94. package/src/lib/get-file-hash.ts +21 -0
  95. package/src/lib/get-file-manifest-entries.ts +126 -0
  96. package/src/lib/get-file-size.ts +23 -0
  97. package/src/lib/get-source-map-url.ts +17 -0
  98. package/src/lib/get-string-details.ts +18 -0
  99. package/src/lib/get-string-hash.ts +15 -0
  100. package/src/lib/maximum-size-transform.ts +29 -0
  101. package/src/lib/modify-url-prefix-transform.ts +55 -0
  102. package/src/lib/no-revision-for-urls-matching-transform.ts +32 -0
  103. package/src/lib/rebase-path.ts +22 -0
  104. package/src/lib/replace-and-update-source-map.ts +122 -0
  105. package/src/lib/serwist-config-error.ts +6 -0
  106. package/src/lib/transform-manifest.ts +158 -0
  107. package/src/lib/translate-url-to-sourcemap-paths.ts +38 -0
  108. package/src/lib/validate-next-options.ts +14 -0
  109. package/src/lib/validate-options.ts +47 -0
  110. package/src/schema/base.ts +16 -0
  111. package/src/schema/getManifest.ts +14 -0
  112. package/src/schema/glob.ts +41 -0
  113. package/src/schema/injectManifest.ts +23 -0
  114. package/src/schema/manifestEntry.ts +9 -0
  115. package/src/schema/manifestTransform.ts +15 -0
  116. package/src/schema/next.ts +35 -0
  117. package/src/schema/swDest.ts +14 -0
  118. package/src/schema/validationErrorMap.ts +36 -0
  119. package/src/schema/vite.ts +18 -0
  120. package/src/schema/webpack.ts +47 -0
  121. package/src/types.ts +407 -0
  122. package/dist/index.cjs +0 -1632
  123. package/dist/lib/cdn-utils.d.ts +0 -1
  124. package/dist/lib/copy-serwist-libraries.d.ts +0 -16
  125. package/dist/schema/index.d.ts +0 -605
package/dist/types.d.ts CHANGED
@@ -1,135 +1,18 @@
1
- import type { QueueOptions } from "@serwist/background-sync";
2
- import type { BroadcastCacheUpdateOptions } from "@serwist/broadcast-update";
3
- import type { CacheableResponseOptions } from "@serwist/cacheable-response";
4
- import type { RouteHandler, RouteMatchCallback, SerwistPlugin } from "@serwist/core";
5
- import type { ExpirationPluginOptions } from "@serwist/expiration";
6
- import type { GoogleAnalyticsInitializeOptions } from "@serwist/google-analytics/initialize";
7
- import type { PrecacheRouteOptions } from "@serwist/precaching";
8
- import type { HTTPMethod } from "@serwist/routing";
1
+ import type { Require } from "@serwist/utils";
2
+ import type { Pattern as GlobPattern } from "fast-glob";
9
3
  import type { PackageJson } from "type-fest";
10
- export interface ManifestEntry {
11
- integrity?: string;
12
- revision: string | null;
13
- url: string;
14
- }
15
- export type StrategyName = "CacheFirst" | "CacheOnly" | "NetworkFirst" | "NetworkOnly" | "StaleWhileRevalidate";
16
- export interface RuntimeCaching {
17
- /**
18
- * This determines how the runtime route will generate a response.
19
- * To use one of the built-in `@serwist/strategies`, provide its name,
20
- * like `'NetworkFirst'`.
21
- * Alternatively, this can be a `@serwist/core.RouteHandler` callback
22
- * function with custom response logic.
23
- */
24
- handler: RouteHandler | StrategyName;
25
- /**
26
- * The HTTP method to match against. The default value of `'GET'` is normally
27
- * sufficient, unless you explicitly need to match `'POST'`, `'PUT'`, or
28
- * another type of request.
29
- * @default "GET"
30
- */
31
- method?: HTTPMethod;
32
- options?: {
33
- /**
34
- * Configuring this will add a
35
- * `@serwist/background-sync.BackgroundSyncPlugin` instance to the
36
- * `@serwist/strategies` configured in `handler`.
37
- */
38
- backgroundSync?: {
39
- name: string;
40
- options?: QueueOptions;
41
- };
42
- /**
43
- * Configuring this will add a
44
- * `@serwist/broadcast-update.BroadcastUpdatePlugin` instance to the
45
- * `@serwist/strategies` configured in `handler`.
46
- */
47
- broadcastUpdate?: {
48
- channelName?: string;
49
- options: BroadcastCacheUpdateOptions;
50
- };
51
- /**
52
- * Configuring this will add a
53
- * `@serwist/cacheable-response.CacheableResponsePlugin` instance to
54
- * the `@serwist/strategies` configured in `handler`.
55
- */
56
- cacheableResponse?: CacheableResponseOptions;
57
- /**
58
- * If provided, this will set the `cacheName` property of the
59
- * `@serwist/strategies` configured in `handler`.
60
- */
61
- cacheName?: string | null;
62
- /**
63
- * Configuring this will add a
64
- * `@serwist/expiration.ExpirationPlugin` instance to
65
- * the `@serwist/strategies` configured in `handler`.
66
- */
67
- expiration?: ExpirationPluginOptions;
68
- /**
69
- * If provided, this will set the `networkTimeoutSeconds` property of the
70
- * `@serwist/strategies` configured in `handler`. Note that only
71
- * `'NetworkFirst'` and `'NetworkOnly'` support `networkTimeoutSeconds`.
72
- */
73
- networkTimeoutSeconds?: number;
74
- /**
75
- * Configuring this allows the use of one or more Serwist plugins that
76
- * don't have "shortcut" options (like `expiration` for
77
- * `@serwist/expiration.ExpirationPlugin`). The plugins provided here
78
- * will be added to the `@serwist/strategies` configured in `handler`.
79
- */
80
- plugins?: Array<SerwistPlugin>;
81
- /**
82
- * Configuring this will add a
83
- * `@serwist/precaching.PrecacheFallbackPlugin` instance to
84
- * the `@serwist/strategies` configured in `handler`.
85
- */
86
- precacheFallback?: {
87
- fallbackURL: string;
88
- };
89
- /**
90
- * Enabling this will add a
91
- * `@serwist/range-requests.RangeRequestsPlugin` instance to
92
- * the `@serwist/strategies` configured in `handler`.
93
- */
94
- rangeRequests?: boolean;
95
- /**
96
- * Configuring this will pass along the `fetchOptions` value to
97
- * the `@serwist/strategies` configured in `handler`.
98
- */
99
- fetchOptions?: RequestInit;
100
- /**
101
- * Configuring this will pass along the `matchOptions` value to
102
- * the `@serwist/strategies` configured in `handler`.
103
- */
104
- matchOptions?: CacheQueryOptions;
105
- };
106
- /**
107
- * This match criteria determines whether the configured handler will
108
- * generate a response for any requests that don't match one of the precached
109
- * URLs. If multiple `RuntimeCaching` routes are defined, then the first one
110
- * whose `urlPattern` matches will be the one that responds.
111
- *
112
- * This value directly maps to the first parameter passed to
113
- * `@serwist/routing.registerRoute`. It's recommended to use a
114
- * `@serwist/core.RouteMatchCallback` function for greatest flexibility.
115
- */
116
- urlPattern: RegExp | string | RouteMatchCallback;
117
- }
118
- export interface ManifestTransformResult {
119
- manifest: Array<ManifestEntry & {
120
- size: number;
121
- }>;
122
- warnings?: Array<string>;
123
- }
124
- export type ManifestTransform = (manifestEntries: Array<ManifestEntry & {
125
- size: number;
126
- }>, compilation?: unknown) => Promise<ManifestTransformResult> | ManifestTransformResult;
4
+ import type { z } from "zod";
5
+ import type { manifestEntry } from "./schema/manifestEntry.js";
6
+ import type { manifestTransform, manifestTransformResult } from "./schema/manifestTransform.js";
7
+ export type ManifestEntry = z.input<typeof manifestEntry>;
8
+ export type ManifestTransformResult = z.input<typeof manifestTransformResult>;
9
+ export type ManifestTransform = z.input<typeof manifestTransform>;
127
10
  export interface BasePartial {
128
11
  /**
129
12
  * A list of entries to be precached, in addition to any entries that are
130
13
  * generated as part of the build configuration.
131
14
  */
132
- additionalPrecacheEntries?: Array<string | ManifestEntry>;
15
+ additionalPrecacheEntries?: (string | ManifestEntry)[];
133
16
  /**
134
17
  * Whether the precache manifest should be set to `undefined`. Essentially whether `@serwist/build` should
135
18
  * be disabled. Mostly useful when you want it to only check if the provided options are valid.
@@ -150,7 +33,7 @@ export interface BasePartial {
150
33
  * generated manifest. If `modifyURLPrefix` or `dontCacheBustURLsMatching` are
151
34
  * also specified, their corresponding transformations will be applied first.
152
35
  */
153
- manifestTransforms?: Array<ManifestTransform>;
36
+ manifestTransforms?: ManifestTransform[];
154
37
  /**
155
38
  * This value can be used to determine the maximum size of files that will be
156
39
  * precached. This prevents you from inadvertently precaching very large files
@@ -181,6 +64,7 @@ export interface BasePartial {
181
64
  [key: string]: string;
182
65
  };
183
66
  }
67
+ export type BaseResolved = Require<BasePartial, "disablePrecacheManifest" | "maximumFileSizeToCacheInBytes">;
184
68
  export interface RequiredGlobDirectoryPartial {
185
69
  /**
186
70
  * The local directory you wish to match `globPatterns` against. The path is
@@ -188,6 +72,7 @@ export interface RequiredGlobDirectoryPartial {
188
72
  */
189
73
  globDirectory: string;
190
74
  }
75
+ export type RequiredGlobDirectoryResolved = RequiredGlobDirectoryPartial;
191
76
  export interface OptionalGlobDirectoryPartial {
192
77
  /**
193
78
  * The local directory you wish to match `globPatterns` against. The path is
@@ -195,39 +80,40 @@ export interface OptionalGlobDirectoryPartial {
195
80
  */
196
81
  globDirectory?: string;
197
82
  }
83
+ export type OptionalGlobDirectoryResolved = OptionalGlobDirectoryPartial;
198
84
  export interface GlobPartial {
199
85
  /**
200
86
  * Determines whether or not symlinks are followed when generating the
201
87
  * precache manifest. For more information, see the definition of `follow` in
202
- * [glob's documentation](https://github.com/isaacs/node-glob#options).
88
+ * [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
203
89
  * @default true
204
90
  */
205
91
  globFollow?: boolean;
206
92
  /**
207
93
  * A set of patterns matching files to always exclude when generating the
208
94
  * precache manifest. For more information, see the definition of `ignore` in
209
- * [glob's documentation](https://github.com/isaacs/node-glob#options).
95
+ * [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
210
96
  * @default
211
97
  * ```
212
98
  * ["**\/node_modules\/**\/*"]
213
99
  * ```
214
100
  */
215
- globIgnores?: Array<string>;
101
+ globIgnores?: string[];
216
102
  /**
217
103
  * Files matching any of these patterns will be included in the precache
218
104
  * manifest. For more information, see
219
- * [glob's Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
105
+ * [`glob`'s Glob Primer](https://github.com/isaacs/node-glob#glob-primer).
220
106
  * @default
221
107
  * ```
222
108
  * ["**\/*.{js,css,html}"]
223
109
  * ```
224
110
  */
225
- globPatterns?: Array<string>;
111
+ globPatterns?: string[];
226
112
  /**
227
113
  * If true, an error reading a directory when generating a precache manifest
228
114
  * will cause the build to fail. If false, the problematic directory will be
229
115
  * skipped. For more information, see the definition of `strict` in
230
- * [glob's documentation](https://github.com/isaacs/node-glob#options).
116
+ * [`glob`'s documentation](https://github.com/isaacs/node-glob#options).
231
117
  * @default true
232
118
  */
233
119
  globStrict?: boolean;
@@ -241,9 +127,10 @@ export interface GlobPartial {
241
127
  * information that you've generated for a given URL.
242
128
  */
243
129
  templatedURLs?: {
244
- [key: string]: string | Array<string>;
130
+ [key: string]: string | string[];
245
131
  };
246
132
  }
133
+ export type GlobResolved = Require<GlobPartial, "globFollow" | "globIgnores" | "globPatterns" | "globStrict">;
247
134
  export interface InjectPartial {
248
135
  /**
249
136
  * The string to find inside of the `swSrc` file. Once found, it will be
@@ -257,32 +144,36 @@ export interface InjectPartial {
257
144
  */
258
145
  swSrc: string;
259
146
  }
147
+ export type InjectResolved = Require<InjectPartial, "injectionPoint">;
260
148
  export interface WebpackPartial {
261
149
  /**
262
150
  * One or more chunk names whose corresponding output files should be included
263
151
  * in the precache manifest.
264
152
  */
265
- chunks?: Array<string>;
153
+ chunks?: string[];
266
154
  /**
267
155
  * One or more specifiers used to exclude assets from the precache manifest.
268
156
  * This is interpreted following
269
157
  * [the same rules](https://webpack.js.org/configuration/module/#condition)
270
158
  * as `webpack`'s standard `exclude` option.
271
- * If not provided, the default value is `[/\.map$/, /^manifest.*\.js$]`.
159
+ * @default
160
+ * ```
161
+ * [/\.map$/, /^manifest.*\.js$]
162
+ * ```
272
163
  */
273
- exclude?: Array<string | RegExp | ((arg0: any) => boolean)>;
164
+ exclude?: (string | RegExp | ((arg0: any) => boolean))[];
274
165
  /**
275
166
  * One or more chunk names whose corresponding output files should be excluded
276
167
  * from the precache manifest.
277
168
  */
278
- excludeChunks?: Array<string>;
169
+ excludeChunks?: string[];
279
170
  /**
280
171
  * One or more specifiers used to include assets in the precache manifest.
281
172
  * This is interpreted following
282
173
  * [the same rules](https://webpack.js.org/configuration/module/#condition)
283
174
  * as `webpack`'s standard `include` option.
284
175
  */
285
- include?: Array<string | RegExp | ((arg0: any) => boolean)>;
176
+ include?: (string | RegExp | ((arg0: any) => boolean))[];
286
177
  /**
287
178
  * If set to 'production', then an optimized service worker bundle that
288
179
  * excludes debugging info will be produced. If not explicitly configured
@@ -291,14 +182,24 @@ export interface WebpackPartial {
291
182
  */
292
183
  mode?: string | null;
293
184
  }
294
- export interface RequiredSWDestPartial {
185
+ export type WebpackResolved = Require<WebpackPartial, "exclude">;
186
+ export interface RequiredSwDestPartial {
295
187
  /**
296
188
  * The path and filename of the service worker file that will be created by
297
- * the build process, relative to the current working directory. It must end
298
- * in '.js'.
189
+ * the build process. It must end in '.js'.
299
190
  */
300
191
  swDest: string;
301
192
  }
193
+ export type RequiredSwDestResolved = RequiredSwDestPartial;
194
+ export interface OptionalSwDestPartial {
195
+ /**
196
+ * The path and filename of the service worker file that will be created by
197
+ * the build process. It must end in '.js'. If omitted, the path will be
198
+ * based on `swSrc`.
199
+ */
200
+ swDest?: string;
201
+ }
202
+ export type OptionalSwDestResolved = OptionalSwDestPartial;
302
203
  export interface WebpackInjectManifestPartial {
303
204
  /**
304
205
  * When `true` (the default), the `swSrc` file will be compiled by `webpack`.
@@ -308,30 +209,120 @@ export interface WebpackInjectManifestPartial {
308
209
  * @default true
309
210
  */
310
211
  compileSrc?: boolean;
311
- /**
312
- * The asset path of the service worker file that will be created by this
313
- * plugin. If omitted, the path will be based on `swSrc` (not applicable for
314
- * `@serwist/next`, which requires this value to always be defined).
315
- */
316
- swDest?: string;
317
212
  /**
318
213
  * Optional `webpack` plugins that will be used when compiling the `swSrc`
319
214
  * input file. Only valid if `compileSrc` is `true`.
320
215
  */
321
- webpackCompilationPlugins?: Array<any>;
216
+ webpackCompilationPlugins?: any[];
322
217
  }
218
+ export type WebpackInjectManifestResolved = Require<WebpackInjectManifestPartial, "compileSrc">;
219
+ export interface NextInjectManifestPartial {
220
+ /**
221
+ * Enable 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
+ cacheOnFrontEndNav?: 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, "cacheOnFrontEndNav" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">;
323
308
  export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;
324
- export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSWDestPartial & RequiredGlobDirectoryPartial;
325
- export type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & WebpackInjectManifestPartial;
326
- export type ViteInjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSWDestPartial & RequiredGlobDirectoryPartial;
309
+ export type GetManifestOptionsComplete = BaseResolved & GlobResolved & RequiredGlobDirectoryResolved;
310
+ export type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSwDestPartial & RequiredGlobDirectoryPartial;
311
+ 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">;
327
318
  export interface GetManifestResult {
328
319
  count: number;
329
- manifestEntries: Array<ManifestEntry> | undefined;
320
+ manifestEntries: ManifestEntry[] | undefined;
330
321
  size: number;
331
- warnings: Array<string>;
322
+ warnings: string[];
332
323
  }
333
324
  export type BuildResult = Omit<GetManifestResult, "manifestEntries"> & {
334
- filePaths: Array<string>;
325
+ filePaths: string[];
335
326
  };
336
327
  /**
337
328
  * @private
@@ -353,23 +344,4 @@ export type SerwistPackageJSON = PackageJson;
353
344
  * @private
354
345
  */
355
346
  export type MethodNames = "GetManifest" | "InjectManifest" | "WebpackInjectManifest" | "ViteInjectManifest";
356
- /**
357
- * @private
358
- */
359
- export interface SerwistSWTemplateOptions {
360
- shouldSkipWaiting: boolean;
361
- scriptsToImport?: string[];
362
- navigationPreload: boolean;
363
- cacheId: string | undefined;
364
- shouldClientsClaim: boolean;
365
- shouldRunPrecacheAndRoute: boolean;
366
- manifestEntries: ManifestEntry[];
367
- precacheOptions: PrecacheRouteOptions;
368
- shouldCleanupOutdatedCaches: boolean;
369
- navigateFallback: string | undefined;
370
- navigateFallbackAllowlist: RegExp[];
371
- navigateFallbackDenylist: RegExp[];
372
- offlineAnalyticsConfig?: boolean | GoogleAnalyticsInitializeOptions;
373
- disableDevLogs: boolean;
374
- runtimeCaching: RuntimeCaching[];
375
- }
347
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/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AAiB,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,CAAC;IACb,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,11 +1,11 @@
1
1
  {
2
2
  "name": "@serwist/build",
3
- "version": "8.4.3",
3
+ "version": "9.0.0-preview.0",
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": [
7
- "dist",
8
- "!dist/**/dts"
7
+ "src",
8
+ "dist"
9
9
  ],
10
10
  "keywords": [
11
11
  "serwist",
@@ -17,56 +17,70 @@
17
17
  "file manifest"
18
18
  ],
19
19
  "engines": {
20
- "node": ">=16.0.0"
20
+ "node": ">=18.0.0"
21
21
  },
22
22
  "author": "Google's Web DevRel Team, Serwist's Team",
23
23
  "license": "MIT",
24
24
  "repository": "serwist/serwist",
25
25
  "bugs": "https://github.com/serwist/serwist/issues",
26
26
  "homepage": "https://serwist.pages.dev",
27
- "module": "./dist/index.js",
28
- "main": "./dist/index.cjs",
27
+ "main": "./dist/index.js",
29
28
  "types": "./dist/index.d.ts",
29
+ "typesVersions": {
30
+ "*": {
31
+ "next": [
32
+ "./dist/index.next.d.ts"
33
+ ]
34
+ }
35
+ },
30
36
  "exports": {
31
37
  ".": {
32
- "import": {
33
- "types": "./dist/index.d.ts",
34
- "default": "./dist/index.js"
35
- },
36
- "require": {
37
- "types": "./dist/index.d.cts",
38
- "default": "./dist/index.cjs"
39
- }
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./next": {
42
+ "types": "./dist/index.next.d.ts",
43
+ "default": "./dist/index.next.js"
40
44
  },
41
45
  "./package.json": "./package.json"
42
46
  },
43
47
  "dependencies": {
44
- "@apideck/better-ajv-errors": "0.3.6",
45
- "ajv": "8.12.0",
46
48
  "common-tags": "1.8.2",
49
+ "fast-glob": "3.3.2",
47
50
  "fast-json-stable-stringify": "2.1.0",
48
51
  "fs-extra": "11.2.0",
49
52
  "glob": "10.3.10",
50
- "rollup": "4.9.1",
53
+ "rollup": "4.9.6",
51
54
  "source-map": "0.8.0-beta.0",
52
55
  "upath": "2.0.1",
53
- "@serwist/background-sync": "8.4.3",
54
- "@serwist/broadcast-update": "8.4.3",
55
- "@serwist/cacheable-response": "8.4.3",
56
- "@serwist/core": "8.4.3",
57
- "@serwist/expiration": "8.4.3",
58
- "@serwist/google-analytics": "8.4.3",
59
- "@serwist/precaching": "8.4.3",
60
- "@serwist/routing": "8.4.3"
56
+ "zod": "3.22.4",
57
+ "@serwist/background-sync": "9.0.0-preview.0",
58
+ "@serwist/broadcast-update": "9.0.0-preview.0",
59
+ "@serwist/cacheable-response": "9.0.0-preview.0",
60
+ "@serwist/core": "9.0.0-preview.0",
61
+ "@serwist/expiration": "9.0.0-preview.0",
62
+ "@serwist/google-analytics": "9.0.0-preview.0",
63
+ "@serwist/precaching": "9.0.0-preview.0",
64
+ "@serwist/routing": "9.0.0-preview.0"
61
65
  },
62
66
  "devDependencies": {
63
67
  "@types/common-tags": "1.8.4",
64
68
  "@types/fs-extra": "11.0.4",
65
- "@types/node": "20.10.5",
69
+ "@types/node": "20.11.16",
66
70
  "@types/stringify-object": "4.0.5",
67
71
  "pretty-bytes": "6.1.1",
68
- "type-fest": "4.8.3",
69
- "@serwist/constants": "8.4.3"
72
+ "type-fest": "4.10.2",
73
+ "typescript": "5.4.0-dev.20240203",
74
+ "@serwist/constants": "9.0.0-preview.0",
75
+ "@serwist/utils": "9.0.0-preview.0"
76
+ },
77
+ "peerDependencies": {
78
+ "typescript": ">=5.0.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "typescript": {
82
+ "optional": true
83
+ }
70
84
  },
71
85
  "scripts": {
72
86
  "build": "rimraf dist && cross-env NODE_OPTIONS='--max-old-space-size=4096' NODE_ENV=production rollup --config rollup.config.js",