@serwist/vite 9.0.15 → 9.1.1

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.
@@ -1,25 +1,42 @@
1
- import { basePartial, globPartial, injectPartial, requiredSwDestPartial, requiredGlobDirectoryPartial } from '@serwist/build/schema';
1
+ import { fn, asyncFn, requiredGlobDirectoryPartial, requiredSwDestPartial, injectPartial, globPartial, basePartial } from '@serwist/build/schema';
2
2
  import { z } from 'zod';
3
3
 
4
4
  const hooks = z.object({
5
- beforeBuildServiceWorker: z.function(z.tuple([
6
- z.any()
7
- ]), z.union([
8
- z.promise(z.void()),
9
- z.void()
10
- ])).optional(),
5
+ beforeBuildServiceWorker: z.union([
6
+ fn({
7
+ input: [
8
+ z.any()
9
+ ],
10
+ output: z.void()
11
+ }),
12
+ asyncFn({
13
+ input: [
14
+ z.any()
15
+ ],
16
+ output: z.void()
17
+ })
18
+ ]).optional(),
11
19
  closeBundleOrder: z.union([
12
20
  z.literal("pre"),
13
21
  z.literal("post"),
14
22
  z.null()
15
23
  ]).optional(),
16
- configureOptions: z.function(z.tuple([
17
- z.any(),
18
- z.any()
19
- ]), z.union([
20
- z.promise(z.void()),
21
- z.void()
22
- ])).optional()
24
+ configureOptions: z.union([
25
+ fn({
26
+ input: [
27
+ z.any(),
28
+ z.any()
29
+ ],
30
+ output: z.void()
31
+ }),
32
+ asyncFn({
33
+ input: [
34
+ z.any(),
35
+ z.any()
36
+ ],
37
+ output: z.void()
38
+ })
39
+ ]).optional()
23
40
  });
24
41
  const devOptions = z.object({
25
42
  bundle: z.boolean().default(true),
@@ -49,8 +66,15 @@ const injectManifestPartial = z.object({
49
66
  z.literal("iife")
50
67
  ]).default("es"),
51
68
  rollupOptions: z.record(z.string(), z.any()).default({}),
52
- devOptions: devOptions.default({})
69
+ devOptions: devOptions.prefault({})
70
+ });
71
+ const injectManifestOptions = z.strictObject({
72
+ ...basePartial.shape,
73
+ ...globPartial.shape,
74
+ ...injectPartial.shape,
75
+ ...requiredSwDestPartial.shape,
76
+ ...requiredGlobDirectoryPartial.shape,
77
+ ...injectManifestPartial.shape
53
78
  });
54
- const injectManifestOptions = basePartial.merge(globPartial).merge(injectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).merge(injectManifestPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
55
79
 
56
80
  export { devOptions, hooks, injectManifestOptions, injectManifestPartial };
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@ import fs from 'node:fs/promises';
4
4
  import path from 'node:path';
5
5
  import fs$1 from 'node:fs';
6
6
  import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
7
+ import { z } from 'zod';
7
8
  import { normalizePath } from 'vite';
8
9
  import process from 'node:process';
9
10
 
10
- var version = "9.0.15";
11
+ var version = "9.1.1";
11
12
  var packageJson = {
12
13
  version: version};
13
14
 
@@ -51,7 +52,7 @@ const injectManifest = async (options)=>{
51
52
  const generateServiceWorker = async (ctx)=>{
52
53
  const { plugins, rollupOptions, rollupFormat } = ctx.options;
53
54
  const parsedSwDest = path.parse(ctx.options.injectManifest.swDest);
54
- let injectManifestResult = undefined;
55
+ let injectManifestResult;
55
56
  if (ctx.options.injectManifest.injectionPoint) {
56
57
  await ctx.options.integration?.beforeBuildServiceWorker?.(ctx.options);
57
58
  injectManifestResult = await injectManifest(ctx.options.injectManifest);
@@ -234,12 +235,12 @@ const toFs = (str)=>{
234
235
 
235
236
  const validateInjectManifestOptions = async (input)=>{
236
237
  const result = await (await import('./chunks/schema.js')).injectManifestOptions.spa(input, {
237
- errorMap: validationErrorMap
238
+ error: validationErrorMap
238
239
  });
239
240
  if (!result.success) {
240
241
  throw new SerwistConfigError({
241
242
  moduleName: "@serwist/vite",
242
- message: JSON.stringify(result.error.format(), null, 2)
243
+ message: z.prettifyError(result.error)
243
244
  });
244
245
  }
245
246
  return result.data;
@@ -1,367 +1,122 @@
1
1
  import { z } from "zod";
2
2
  export declare const hooks: z.ZodObject<{
3
- beforeBuildServiceWorker: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
4
- closeBundleOrder: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
5
- configureOptions: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
6
- }, "strip", z.ZodTypeAny, {
7
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
8
- closeBundleOrder?: "pre" | "post" | null | undefined;
9
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
10
- }, {
11
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
12
- closeBundleOrder?: "pre" | "post" | null | undefined;
13
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
14
- }>;
3
+ beforeBuildServiceWorker: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>]>>;
4
+ closeBundleOrder: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
5
+ configureOptions: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any, args_1: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>]>>;
6
+ }, z.core.$strip>;
15
7
  export declare const devOptions: z.ZodObject<{
16
8
  bundle: z.ZodDefault<z.ZodBoolean>;
17
- minify: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
18
- }, "strip", z.ZodTypeAny, {
19
- bundle: boolean;
20
- minify: boolean | "terser" | "esbuild";
21
- }, {
22
- bundle?: boolean | undefined;
23
- minify?: boolean | "terser" | "esbuild" | undefined;
24
- }>;
9
+ minify: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
10
+ }, z.core.$strip>;
25
11
  export declare const injectManifestPartial: z.ZodObject<{
26
- mode: z.ZodUnion<[z.ZodLiteral<"development">, z.ZodLiteral<"production">]>;
27
- type: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"module">]>>;
12
+ mode: z.ZodUnion<readonly [z.ZodLiteral<"development">, z.ZodLiteral<"production">]>;
13
+ type: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"classic">, z.ZodLiteral<"module">]>>;
28
14
  scope: z.ZodString;
29
15
  base: z.ZodString;
30
16
  disable: z.ZodDefault<z.ZodBoolean>;
31
17
  integration: z.ZodDefault<z.ZodObject<{
32
- beforeBuildServiceWorker: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
33
- closeBundleOrder: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
34
- configureOptions: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
35
- }, "strip", z.ZodTypeAny, {
36
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
37
- closeBundleOrder?: "pre" | "post" | null | undefined;
38
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
39
- }, {
40
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
41
- closeBundleOrder?: "pre" | "post" | null | undefined;
42
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
43
- }>>;
18
+ beforeBuildServiceWorker: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>]>>;
19
+ closeBundleOrder: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
20
+ configureOptions: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any, args_1: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>]>>;
21
+ }, z.core.$strip>>;
44
22
  swUrl: z.ZodDefault<z.ZodString>;
45
- plugins: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
46
- rollupFormat: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"iife">]>>;
23
+ plugins: z.ZodDefault<z.ZodArray<z.ZodAny>>;
24
+ rollupFormat: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"es">, z.ZodLiteral<"iife">]>>;
47
25
  rollupOptions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
48
- devOptions: z.ZodDefault<z.ZodObject<{
26
+ devOptions: z.ZodPrefault<z.ZodObject<{
49
27
  bundle: z.ZodDefault<z.ZodBoolean>;
50
- minify: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
51
- }, "strip", z.ZodTypeAny, {
52
- bundle: boolean;
53
- minify: boolean | "terser" | "esbuild";
54
- }, {
55
- bundle?: boolean | undefined;
56
- minify?: boolean | "terser" | "esbuild" | undefined;
57
- }>>;
58
- }, "strip", z.ZodTypeAny, {
59
- type: "classic" | "module";
60
- mode: "development" | "production";
61
- scope: string;
62
- base: string;
63
- disable: boolean;
64
- integration: {
65
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
66
- closeBundleOrder?: "pre" | "post" | null | undefined;
67
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
68
- };
69
- swUrl: string;
70
- plugins: any[];
71
- rollupFormat: "es" | "iife";
72
- rollupOptions: Record<string, any>;
73
- devOptions: {
74
- bundle: boolean;
75
- minify: boolean | "terser" | "esbuild";
76
- };
77
- }, {
78
- mode: "development" | "production";
79
- scope: string;
80
- base: string;
81
- type?: "classic" | "module" | undefined;
82
- disable?: boolean | undefined;
83
- integration?: {
84
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
85
- closeBundleOrder?: "pre" | "post" | null | undefined;
86
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
87
- } | undefined;
88
- swUrl?: string | undefined;
89
- plugins?: any[] | undefined;
90
- rollupFormat?: "es" | "iife" | undefined;
91
- rollupOptions?: Record<string, any> | undefined;
92
- devOptions?: {
93
- bundle?: boolean | undefined;
94
- minify?: boolean | "terser" | "esbuild" | undefined;
95
- } | undefined;
96
- }>;
28
+ minify: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
29
+ }, z.core.$strip>>;
30
+ }, z.core.$strip>;
97
31
  export declare const injectManifestOptions: z.ZodObject<{
98
- additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
32
+ mode: z.ZodUnion<readonly [z.ZodLiteral<"development">, z.ZodLiteral<"production">]>;
33
+ type: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"classic">, z.ZodLiteral<"module">]>>;
34
+ scope: z.ZodString;
35
+ base: z.ZodString;
36
+ disable: z.ZodDefault<z.ZodBoolean>;
37
+ integration: z.ZodDefault<z.ZodObject<{
38
+ beforeBuildServiceWorker: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny], null>, z.ZodVoid>>>]>>;
39
+ closeBundleOrder: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
40
+ configureOptions: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<(args_0: any, args_1: any) => void, z.core.$InferInnerFunctionType<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>, z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodVoid>>>]>>;
41
+ }, z.core.$strip>>;
42
+ swUrl: z.ZodDefault<z.ZodString>;
43
+ plugins: z.ZodDefault<z.ZodArray<z.ZodAny>>;
44
+ rollupFormat: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"es">, z.ZodLiteral<"iife">]>>;
45
+ rollupOptions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
46
+ devOptions: z.ZodPrefault<z.ZodObject<{
47
+ bundle: z.ZodDefault<z.ZodBoolean>;
48
+ minify: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
49
+ }, z.core.$strip>>;
50
+ globDirectory: z.ZodString;
51
+ swDest: z.ZodString;
52
+ injectionPoint: z.ZodDefault<z.ZodString>;
53
+ swSrc: z.ZodString;
54
+ globFollow: z.ZodDefault<z.ZodBoolean>;
55
+ globIgnores: z.ZodDefault<z.ZodArray<z.ZodString>>;
56
+ globPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
57
+ globStrict: z.ZodDefault<z.ZodBoolean>;
58
+ templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
59
+ additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
99
60
  integrity: z.ZodOptional<z.ZodString>;
100
61
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
62
  url: z.ZodString;
102
- }, "strict", z.ZodTypeAny, {
103
- url: string;
104
- integrity?: string | undefined;
105
- revision?: string | null | undefined;
106
- }, {
107
- url: string;
108
- integrity?: string | undefined;
109
- revision?: string | null | undefined;
110
- }>]>, "many">>;
63
+ }, z.core.$strict>]>>>;
111
64
  disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
112
- dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>;
113
- manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
65
+ dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
66
+ manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
67
+ size: z.ZodNumber;
114
68
  integrity: z.ZodOptional<z.ZodString>;
115
69
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
116
70
  url: z.ZodString;
117
- } & {
118
- size: z.ZodNumber;
119
- }, "strip", z.ZodTypeAny, {
120
- url: string;
121
- size: number;
122
- integrity?: string | undefined;
123
- revision?: string | null | undefined;
124
- }, {
125
- url: string;
126
- size: number;
127
- integrity?: string | undefined;
128
- revision?: string | null | undefined;
129
- }>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
71
+ }, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
130
72
  manifest: z.ZodArray<z.ZodObject<{
73
+ size: z.ZodNumber;
131
74
  integrity: z.ZodOptional<z.ZodString>;
132
75
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
133
76
  url: z.ZodString;
134
- } & {
77
+ }, z.core.$strip>>;
78
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
79
+ }, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
80
+ size: z.ZodNumber;
81
+ integrity: z.ZodOptional<z.ZodString>;
82
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ url: z.ZodString;
84
+ }, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
85
+ manifest: z.ZodArray<z.ZodObject<{
135
86
  size: z.ZodNumber;
136
- }, "strip", z.ZodTypeAny, {
137
- url: string;
138
- size: number;
139
- integrity?: string | undefined;
140
- revision?: string | null | undefined;
141
- }, {
142
- url: string;
143
- size: number;
144
- integrity?: string | undefined;
145
- revision?: string | null | undefined;
146
- }>, "many">;
147
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
148
- }, "strict", z.ZodTypeAny, {
149
- manifest: {
150
- url: string;
151
- size: number;
152
- integrity?: string | undefined;
153
- revision?: string | null | undefined;
154
- }[];
155
- warnings?: string[] | undefined;
156
- }, {
157
- manifest: {
158
- url: string;
159
- size: number;
160
- integrity?: string | undefined;
161
- revision?: string | null | undefined;
162
- }[];
163
- warnings?: string[] | undefined;
164
- }>>, z.ZodObject<{
87
+ integrity: z.ZodOptional<z.ZodString>;
88
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
+ url: z.ZodString;
90
+ }, z.core.$strip>>;
91
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
92
+ }, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
93
+ size: z.ZodNumber;
94
+ integrity: z.ZodOptional<z.ZodString>;
95
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ url: z.ZodString;
97
+ }, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
165
98
  manifest: z.ZodArray<z.ZodObject<{
99
+ size: z.ZodNumber;
166
100
  integrity: z.ZodOptional<z.ZodString>;
167
101
  revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
168
102
  url: z.ZodString;
169
- } & {
103
+ }, z.core.$strip>>;
104
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
+ }, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
106
+ size: z.ZodNumber;
107
+ integrity: z.ZodOptional<z.ZodString>;
108
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
+ url: z.ZodString;
110
+ }, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
111
+ manifest: z.ZodArray<z.ZodObject<{
170
112
  size: z.ZodNumber;
171
- }, "strip", z.ZodTypeAny, {
172
- url: string;
173
- size: number;
174
- integrity?: string | undefined;
175
- revision?: string | null | undefined;
176
- }, {
177
- url: string;
178
- size: number;
179
- integrity?: string | undefined;
180
- revision?: string | null | undefined;
181
- }>, "many">;
182
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
183
- }, "strict", z.ZodTypeAny, {
184
- manifest: {
185
- url: string;
186
- size: number;
187
- integrity?: string | undefined;
188
- revision?: string | null | undefined;
189
- }[];
190
- warnings?: string[] | undefined;
191
- }, {
192
- manifest: {
193
- url: string;
194
- size: number;
195
- integrity?: string | undefined;
196
- revision?: string | null | undefined;
197
- }[];
198
- warnings?: string[] | undefined;
199
- }>]>>, "many">>;
113
+ integrity: z.ZodOptional<z.ZodString>;
114
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
115
+ url: z.ZodString;
116
+ }, z.core.$strip>>;
117
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ }, z.core.$strict>>>>>>;
200
119
  maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
201
120
  modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
202
- } & {
203
- globFollow: z.ZodDefault<z.ZodBoolean>;
204
- globIgnores: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
205
- globPatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
206
- globStrict: z.ZodDefault<z.ZodBoolean>;
207
- templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
208
- } & {
209
- injectionPoint: z.ZodDefault<z.ZodString>;
210
- swSrc: z.ZodString;
211
- } & {
212
- swDest: z.ZodString;
213
- } & {
214
- globDirectory: z.ZodString;
215
- } & {
216
- mode: z.ZodUnion<[z.ZodLiteral<"development">, z.ZodLiteral<"production">]>;
217
- type: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"module">]>>;
218
- scope: z.ZodString;
219
- base: z.ZodString;
220
- disable: z.ZodDefault<z.ZodBoolean>;
221
- integration: z.ZodDefault<z.ZodObject<{
222
- beforeBuildServiceWorker: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
223
- closeBundleOrder: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"pre">, z.ZodLiteral<"post">, z.ZodNull]>>;
224
- configureOptions: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny, z.ZodAny], null>, z.ZodUnion<[z.ZodPromise<z.ZodVoid>, z.ZodVoid]>>>;
225
- }, "strip", z.ZodTypeAny, {
226
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
227
- closeBundleOrder?: "pre" | "post" | null | undefined;
228
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
229
- }, {
230
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
231
- closeBundleOrder?: "pre" | "post" | null | undefined;
232
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
233
- }>>;
234
- swUrl: z.ZodDefault<z.ZodString>;
235
- plugins: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
236
- rollupFormat: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"es">, z.ZodLiteral<"iife">]>>;
237
- rollupOptions: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
238
- devOptions: z.ZodDefault<z.ZodObject<{
239
- bundle: z.ZodDefault<z.ZodBoolean>;
240
- minify: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"terser">, z.ZodLiteral<"esbuild">]>>;
241
- }, "strip", z.ZodTypeAny, {
242
- bundle: boolean;
243
- minify: boolean | "terser" | "esbuild";
244
- }, {
245
- bundle?: boolean | undefined;
246
- minify?: boolean | "terser" | "esbuild" | undefined;
247
- }>>;
248
- }, "strict", z.ZodTypeAny, {
249
- type: "classic" | "module";
250
- mode: "development" | "production";
251
- scope: string;
252
- base: string;
253
- disable: boolean;
254
- integration: {
255
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
256
- closeBundleOrder?: "pre" | "post" | null | undefined;
257
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
258
- };
259
- swUrl: string;
260
- plugins: any[];
261
- rollupFormat: "es" | "iife";
262
- rollupOptions: Record<string, any>;
263
- devOptions: {
264
- bundle: boolean;
265
- minify: boolean | "terser" | "esbuild";
266
- };
267
- disablePrecacheManifest: boolean;
268
- maximumFileSizeToCacheInBytes: number;
269
- globFollow: boolean;
270
- globIgnores: string[];
271
- globPatterns: string[];
272
- globStrict: boolean;
273
- injectionPoint: string;
274
- swSrc: string;
275
- swDest: string;
276
- globDirectory: string;
277
- additionalPrecacheEntries?: (string | {
278
- url: string;
279
- integrity?: string | undefined;
280
- revision?: string | null | undefined;
281
- })[] | undefined;
282
- dontCacheBustURLsMatching?: RegExp | undefined;
283
- manifestTransforms?: ((args_0: {
284
- url: string;
285
- size: number;
286
- integrity?: string | undefined;
287
- revision?: string | null | undefined;
288
- }[], args_1: unknown) => {
289
- manifest: {
290
- url: string;
291
- size: number;
292
- integrity?: string | undefined;
293
- revision?: string | null | undefined;
294
- }[];
295
- warnings?: string[] | undefined;
296
- } | Promise<{
297
- manifest: {
298
- url: string;
299
- size: number;
300
- integrity?: string | undefined;
301
- revision?: string | null | undefined;
302
- }[];
303
- warnings?: string[] | undefined;
304
- }>)[] | undefined;
305
- modifyURLPrefix?: Record<string, string> | undefined;
306
- templatedURLs?: Record<string, string | string[]> | undefined;
307
- }, {
308
- mode: "development" | "production";
309
- scope: string;
310
- base: string;
311
- swSrc: string;
312
- swDest: string;
313
- globDirectory: string;
314
- type?: "classic" | "module" | undefined;
315
- disable?: boolean | undefined;
316
- integration?: {
317
- beforeBuildServiceWorker?: ((args_0: any) => void | Promise<void>) | undefined;
318
- closeBundleOrder?: "pre" | "post" | null | undefined;
319
- configureOptions?: ((args_0: any, args_1: any) => void | Promise<void>) | undefined;
320
- } | undefined;
321
- swUrl?: string | undefined;
322
- plugins?: any[] | undefined;
323
- rollupFormat?: "es" | "iife" | undefined;
324
- rollupOptions?: Record<string, any> | undefined;
325
- devOptions?: {
326
- bundle?: boolean | undefined;
327
- minify?: boolean | "terser" | "esbuild" | undefined;
328
- } | undefined;
329
- additionalPrecacheEntries?: (string | {
330
- url: string;
331
- integrity?: string | undefined;
332
- revision?: string | null | undefined;
333
- })[] | undefined;
334
- disablePrecacheManifest?: boolean | undefined;
335
- dontCacheBustURLsMatching?: RegExp | undefined;
336
- manifestTransforms?: ((args_0: {
337
- url: string;
338
- size: number;
339
- integrity?: string | undefined;
340
- revision?: string | null | undefined;
341
- }[], args_1: unknown) => {
342
- manifest: {
343
- url: string;
344
- size: number;
345
- integrity?: string | undefined;
346
- revision?: string | null | undefined;
347
- }[];
348
- warnings?: string[] | undefined;
349
- } | Promise<{
350
- manifest: {
351
- url: string;
352
- size: number;
353
- integrity?: string | undefined;
354
- revision?: string | null | undefined;
355
- }[];
356
- warnings?: string[] | undefined;
357
- }>)[] | undefined;
358
- maximumFileSizeToCacheInBytes?: number | undefined;
359
- modifyURLPrefix?: Record<string, string> | undefined;
360
- globFollow?: boolean | undefined;
361
- globIgnores?: string[] | undefined;
362
- globPatterns?: string[] | undefined;
363
- globStrict?: boolean | undefined;
364
- templatedURLs?: Record<string, string | string[]> | undefined;
365
- injectionPoint?: string | undefined;
366
- }>;
121
+ }, z.core.$strict>;
367
122
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK;;;;;;;;;;;;EAIhB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;EAGrB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;iBAvBkC,CAAC;gBACnD,CAAC;;;iBAA4E,CAAC;gBAGjF,CAAC;;;;;;;;;;;;;iBAcR,CAAC;gBAAsC,CAAC;;;;iBAEvC,CAAC;gBAGL,CAAC;;;;;;;;;;;qBAOmM,CAAC;oBAA0C,CAAC;;;;qBAAkH,CAAC;oBAA0C,CAAC;;;;;;;qBAAiP,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;qBAA6H,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;;;;;;;qBAAqY,CAAC;oBAA0C,CAAC;;;;qBAAkH,CAAC;oBAA0C,CAAC;;;;;;;qBAAiP,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;qBAA6H,CAAC;oBAA0C,CAAC;;gBAA0D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAA3U,CAAC;oBAA0C,CAAC;;;;;;;qBAAvrC,CAAC;oBAA0C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAAm0C,CAAC;oBAA0C,CAAC;;;;;;;qBAAvrC,CAAC;oBAA0C,CAAC;;;;;;;;;;;;EAD/0B,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK;;;;iBA0BhB,CAAC;AAEH,eAAO,MAAM,UAAU;;;iBAGrB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAYhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,GAAU,OAAO,OAAO,KAAG,OAAO,CAAC,6BAA6B,CAMzG,CAAC"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/lib/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,6BAA6B,GAAU,OAAO,OAAO,KAAG,OAAO,CAAC,6BAA6B,CAMzG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/vite",
3
- "version": "9.0.15",
3
+ "version": "9.1.1",
4
4
  "type": "module",
5
5
  "description": "A module that integrates Serwist into your Vite application.",
6
6
  "files": [
@@ -74,19 +74,19 @@
74
74
  "dependencies": {
75
75
  "glob": "10.4.5",
76
76
  "kolorist": "1.8.0",
77
- "zod": "3.25.63",
78
- "@serwist/build": "9.0.15",
79
- "serwist": "9.0.15"
77
+ "zod": "4.0.5",
78
+ "@serwist/build": "9.1.1",
79
+ "serwist": "9.1.1"
80
80
  },
81
81
  "devDependencies": {
82
- "@types/node": "24.0.1",
83
- "rollup": "4.43.0",
82
+ "@types/node": "24.0.14",
83
+ "rollup": "4.45.1",
84
84
  "typescript": "5.8.3",
85
- "vite": "6.3.5",
86
- "@serwist/configs": "9.0.15",
87
- "serwist": "9.0.15",
88
- "@serwist/utils": "9.0.15",
89
- "@serwist/window": "9.0.15"
85
+ "vite": "7.0.4",
86
+ "@serwist/configs": "9.1.1",
87
+ "serwist": "9.1.1",
88
+ "@serwist/utils": "9.1.1",
89
+ "@serwist/window": "9.1.1"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "typescript": ">=5.0.0",
@@ -39,7 +39,7 @@ export const generateServiceWorker = async (ctx: SerwistViteContext) => {
39
39
 
40
40
  const parsedSwDest = path.parse(ctx.options.injectManifest.swDest);
41
41
 
42
- let injectManifestResult: BuildResult | undefined = undefined;
42
+ let injectManifestResult: BuildResult | undefined;
43
43
 
44
44
  if (ctx.options.injectManifest.injectionPoint) {
45
45
  await ctx.options.integration?.beforeBuildServiceWorker?.(ctx.options);
package/src/lib/schema.ts CHANGED
@@ -1,10 +1,32 @@
1
- import { basePartial, globPartial, injectPartial, requiredGlobDirectoryPartial, requiredSwDestPartial } from "@serwist/build/schema";
1
+ import { fn, basePartial, globPartial, injectPartial, requiredGlobDirectoryPartial, requiredSwDestPartial, asyncFn } from "@serwist/build/schema";
2
2
  import { z } from "zod";
3
3
 
4
4
  export const hooks = z.object({
5
- beforeBuildServiceWorker: z.function(z.tuple([z.any()]), z.union([z.promise(z.void()), z.void()])).optional(),
5
+ beforeBuildServiceWorker: z
6
+ .union([
7
+ fn({
8
+ input: [z.any()],
9
+ output: z.void(),
10
+ }),
11
+ asyncFn({
12
+ input: [z.any()],
13
+ output: z.void(),
14
+ }),
15
+ ])
16
+ .optional(),
6
17
  closeBundleOrder: z.union([z.literal("pre"), z.literal("post"), z.null()]).optional(),
7
- configureOptions: z.function(z.tuple([z.any(), z.any()]), z.union([z.promise(z.void()), z.void()])).optional(),
18
+ configureOptions: z
19
+ .union([
20
+ fn({
21
+ input: [z.any(), z.any()],
22
+ output: z.void(),
23
+ }),
24
+ asyncFn({
25
+ input: [z.any(), z.any()],
26
+ output: z.void(),
27
+ }),
28
+ ])
29
+ .optional(),
8
30
  });
9
31
 
10
32
  export const devOptions = z.object({
@@ -23,13 +45,14 @@ export const injectManifestPartial = z.object({
23
45
  plugins: z.array(z.any()).default([]),
24
46
  rollupFormat: z.union([z.literal("es"), z.literal("iife")]).default("es"),
25
47
  rollupOptions: z.record(z.string(), z.any()).default({}),
26
- devOptions: devOptions.default({}),
48
+ devOptions: devOptions.prefault({}),
27
49
  });
28
50
 
29
- export const injectManifestOptions = basePartial
30
- .merge(globPartial)
31
- .merge(injectPartial)
32
- .merge(requiredSwDestPartial)
33
- .merge(requiredGlobDirectoryPartial)
34
- .merge(injectManifestPartial)
35
- .strict("Do not pass invalid properties to InjectManifestOptions!");
51
+ export const injectManifestOptions = z.strictObject({
52
+ ...basePartial.shape,
53
+ ...globPartial.shape,
54
+ ...injectPartial.shape,
55
+ ...requiredSwDestPartial.shape,
56
+ ...requiredGlobDirectoryPartial.shape,
57
+ ...injectManifestPartial.shape,
58
+ });
@@ -1,10 +1,11 @@
1
1
  import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
2
+ import { z } from "zod";
2
3
  import type { InjectManifestOptionsComplete } from "./types.js";
3
4
 
4
5
  export const validateInjectManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {
5
- const result = await (await import("./schema.js")).injectManifestOptions.spa(input, { errorMap: validationErrorMap });
6
+ const result = await (await import("./schema.js")).injectManifestOptions.spa(input, { error: validationErrorMap });
6
7
  if (!result.success) {
7
- throw new SerwistConfigError({ moduleName: "@serwist/vite", message: JSON.stringify(result.error.format(), null, 2) });
8
+ throw new SerwistConfigError({ moduleName: "@serwist/vite", message: z.prettifyError(result.error) });
8
9
  }
9
10
  return result.data;
10
11
  };