@serwist/build 9.0.0-preview.8 → 9.0.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 (74) hide show
  1. package/dist/chunks/glob.js +3 -3
  2. package/dist/chunks/injectManifest.js +5 -5
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +24 -50
  6. package/dist/index.schema.d.ts +13 -0
  7. package/dist/index.schema.d.ts.map +1 -0
  8. package/dist/index.schema.js +9 -0
  9. package/dist/lib/additional-precache-entries-transform.d.ts +6 -8
  10. package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -1
  11. package/dist/lib/get-file-details.d.ts +3 -9
  12. package/dist/lib/get-file-details.d.ts.map +1 -1
  13. package/dist/lib/get-file-hash.d.ts +1 -1
  14. package/dist/lib/get-file-hash.d.ts.map +1 -1
  15. package/dist/lib/get-file-manifest-entries.d.ts +2 -2
  16. package/dist/lib/get-file-manifest-entries.d.ts.map +1 -1
  17. package/dist/lib/get-string-details.d.ts +1 -1
  18. package/dist/lib/get-string-details.d.ts.map +1 -1
  19. package/dist/lib/get-string-hash.d.ts +1 -1
  20. package/dist/lib/get-string-hash.d.ts.map +1 -1
  21. package/dist/lib/transform-manifest.d.ts +4 -3
  22. package/dist/lib/transform-manifest.d.ts.map +1 -1
  23. package/dist/lib/validate-options.d.ts +1 -3
  24. package/dist/lib/validate-options.d.ts.map +1 -1
  25. package/dist/schema/assertType.d.ts +1 -0
  26. package/dist/schema/assertType.d.ts.map +1 -1
  27. package/dist/schema/base.d.ts +24 -24
  28. package/dist/schema/getManifest.d.ts +24 -24
  29. package/dist/schema/injectManifest.d.ts +27 -27
  30. package/dist/schema/injectManifest.d.ts.map +1 -1
  31. package/dist/schema/manifestEntry.d.ts +3 -3
  32. package/dist/schema/manifestTransform.d.ts +18 -18
  33. package/dist/{lib/serwist-config-error.d.ts → schema/serwistConfigError.d.ts} +1 -1
  34. package/dist/schema/serwistConfigError.d.ts.map +1 -0
  35. package/dist/types.d.ts +9 -152
  36. package/dist/types.d.ts.map +1 -1
  37. package/package.json +15 -24
  38. package/src/index.schema.ts +29 -0
  39. package/src/index.ts +2 -3
  40. package/src/inject-manifest.ts +1 -1
  41. package/src/lib/additional-precache-entries-transform.ts +4 -8
  42. package/src/lib/get-composite-details.ts +2 -2
  43. package/src/lib/get-file-details.ts +9 -17
  44. package/src/lib/get-file-hash.ts +4 -4
  45. package/src/lib/get-file-manifest-entries.ts +5 -5
  46. package/src/lib/get-string-details.ts +5 -7
  47. package/src/lib/get-string-hash.ts +1 -1
  48. package/src/lib/transform-manifest.ts +28 -16
  49. package/src/lib/validate-options.ts +2 -23
  50. package/src/schema/assertType.ts +2 -0
  51. package/src/schema/injectManifest.ts +4 -4
  52. package/src/schema/manifestEntry.ts +1 -1
  53. package/src/types.ts +9 -184
  54. package/dist/chunks/vite.js +0 -7
  55. package/dist/chunks/webpack.js +0 -33
  56. package/dist/index.next.d.ts +0 -3
  57. package/dist/index.next.d.ts.map +0 -1
  58. package/dist/index.next.js +0 -38
  59. package/dist/lib/serwist-config-error.d.ts.map +0 -1
  60. package/dist/lib/validate-next-options.d.ts +0 -3
  61. package/dist/lib/validate-next-options.d.ts.map +0 -1
  62. package/dist/schema/next.d.ts +0 -240
  63. package/dist/schema/next.d.ts.map +0 -1
  64. package/dist/schema/vite.d.ts +0 -196
  65. package/dist/schema/vite.d.ts.map +0 -1
  66. package/dist/schema/webpack.d.ts +0 -225
  67. package/dist/schema/webpack.d.ts.map +0 -1
  68. package/src/index.next.ts +0 -3
  69. package/src/lib/validate-next-options.ts +0 -14
  70. package/src/schema/next.ts +0 -33
  71. package/src/schema/vite.ts +0 -18
  72. package/src/schema/webpack.ts +0 -46
  73. package/dist/chunks/{serwist-config-error.js → validationErrorMap.js} +7 -7
  74. /package/src/{lib/serwist-config-error.ts → schema/serwistConfigError.ts} +0 -0
@@ -1,33 +0,0 @@
1
- import { z } from "zod";
2
- import type {
3
- NextInjectManifestOptions,
4
- NextInjectManifestOptionsComplete,
5
- NextInjectManifestPartial,
6
- NextInjectManifestResolved,
7
- } from "../types.js";
8
- import { type Equals, assertType } from "./assertType.js";
9
- import { requiredSwDestPartial } from "./swDest.js";
10
- import { webpackInjectManifestOptions } from "./webpack.js";
11
-
12
- export const nextInjectManifestPartial = z
13
- .object({
14
- cacheOnNavigation: z.boolean().default(false),
15
- disable: z.boolean().default(false),
16
- register: z.boolean().default(true),
17
- reloadOnOnline: z.boolean().default(true),
18
- scope: z.string().optional(),
19
- swUrl: z.string().default("/sw.js"),
20
- globPublicPatterns: z.union([z.string(), z.array(z.string())]).default(["**/*"]),
21
- })
22
- .strict("Do not pass invalid properties to NextInjectManifestPartial!");
23
-
24
- export const nextInjectManifestOptions = webpackInjectManifestOptions
25
- .merge(requiredSwDestPartial)
26
- .merge(nextInjectManifestPartial)
27
- .omit({ disablePrecacheManifest: true })
28
- .strict("Do not pass invalid properties to NextInjectManifestOptions!");
29
-
30
- assertType<Equals<NextInjectManifestPartial, z.input<typeof nextInjectManifestPartial>>>();
31
- assertType<Equals<NextInjectManifestResolved, z.output<typeof nextInjectManifestPartial>>>();
32
- assertType<Equals<NextInjectManifestOptions, z.input<typeof nextInjectManifestOptions>>>();
33
- assertType<Equals<NextInjectManifestOptionsComplete, z.output<typeof nextInjectManifestOptions>>>();
@@ -1,18 +0,0 @@
1
- import type { z } from "zod";
2
- import type { ViteInjectManifestOptions, ViteInjectManifestOptionsComplete } from "../types.js";
3
- import { type Equals, assertType } from "./assertType.js";
4
- import { basePartial } from "./base.js";
5
- import { globPartial } from "./glob.js";
6
- import { requiredGlobDirectoryPartial } from "./glob.js";
7
- import { injectPartial } from "./injectManifest.js";
8
- import { requiredSwDestPartial } from "./swDest.js";
9
-
10
- export const viteInjectManifestOptions = basePartial
11
- .merge(globPartial)
12
- .merge(injectPartial)
13
- .merge(requiredSwDestPartial)
14
- .merge(requiredGlobDirectoryPartial)
15
- .strict("Do not pass invalid properties to ViteInjectManifestPartial!");
16
-
17
- assertType<Equals<ViteInjectManifestOptions, z.input<typeof viteInjectManifestOptions>>>();
18
- assertType<Equals<ViteInjectManifestOptionsComplete, z.output<typeof viteInjectManifestOptions>>>();
@@ -1,46 +0,0 @@
1
- import { z } from "zod";
2
- import type {
3
- WebpackInjectManifestOptions,
4
- WebpackInjectManifestOptionsComplete,
5
- WebpackInjectManifestPartial,
6
- WebpackInjectManifestResolved,
7
- WebpackPartial,
8
- WebpackResolved,
9
- } from "../types.js";
10
- import { type Equals, assertType } from "./assertType.js";
11
- import { basePartial } from "./base.js";
12
- import { injectPartial } from "./injectManifest.js";
13
- import { optionalSwDestPartial } from "./swDest.js";
14
-
15
- export const webpackPartial = z
16
- .object({
17
- chunks: z.array(z.string()).optional(),
18
- exclude: z
19
- .array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())]))
20
- .default([/\.map$/, /^manifest.*\.js$/]),
21
- excludeChunks: z.array(z.string()).optional(),
22
- include: z.array(z.union([z.string(), z.instanceof(RegExp), z.function(z.tuple([z.any()]), z.boolean())])).optional(),
23
- })
24
- .strict("Do not pass invalid properties to WebpackPartial!");
25
-
26
- export const webpackInjectManifestPartial = z
27
- .object({
28
- compileSrc: z.boolean().default(true),
29
- swDest: z.string().optional(),
30
- webpackCompilationPlugins: z.array(z.any()).optional(),
31
- })
32
- .strict("Do not pass invalid properties to WebpackInjectManifestPartial!");
33
-
34
- export const webpackInjectManifestOptions = basePartial
35
- .merge(webpackPartial)
36
- .merge(injectPartial)
37
- .merge(optionalSwDestPartial)
38
- .merge(webpackInjectManifestPartial)
39
- .strict("Do not pass invalid properties to WebpackInjectManifestOptions!");
40
-
41
- assertType<Equals<z.input<typeof webpackPartial>, WebpackPartial>>();
42
- assertType<Equals<WebpackResolved, z.output<typeof webpackPartial>>>();
43
- assertType<Equals<WebpackInjectManifestPartial, z.input<typeof webpackInjectManifestPartial>>>();
44
- assertType<Equals<WebpackInjectManifestResolved, z.output<typeof webpackInjectManifestPartial>>>();
45
- assertType<Equals<WebpackInjectManifestOptions, z.input<typeof webpackInjectManifestOptions>>>();
46
- assertType<Equals<WebpackInjectManifestOptionsComplete, z.output<typeof webpackInjectManifestOptions>>>();
@@ -1,5 +1,12 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ class SerwistConfigError extends Error {
4
+ constructor({ moduleName, message }){
5
+ super(`Received an invalid ${moduleName ?? "Serwist"} configuration: ${message}`);
6
+ Object.setPrototypeOf(this, new.target.prototype);
7
+ }
8
+ }
9
+
3
10
  const validationErrorMap = (error, ctx)=>{
4
11
  switch(error.code){
5
12
  case z.ZodIssueCode.invalid_type:
@@ -44,11 +51,4 @@ const validationErrorMap = (error, ctx)=>{
44
51
  };
45
52
  };
46
53
 
47
- class SerwistConfigError extends Error {
48
- constructor({ moduleName, message }){
49
- super(`Received an invalid ${moduleName ?? "Serwist"} configuration: ${message}`);
50
- Object.setPrototypeOf(this, new.target.prototype);
51
- }
52
- }
53
-
54
54
  export { SerwistConfigError as S, validationErrorMap as v };