@serwist/build 9.0.15 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/error.js +55 -0
- package/dist/chunks/get-manifest.js +10 -0
- package/dist/chunks/glob.js +43 -25
- package/dist/chunks/inject-manifest.js +29 -0
- package/dist/index.js +11 -11
- package/dist/index.schema.d.ts +9 -9
- package/dist/index.schema.d.ts.map +1 -1
- package/dist/index.schema.js +4 -4
- package/dist/lib/transform-manifest.d.ts.map +1 -1
- package/dist/lib/validate-options.d.ts.map +1 -1
- package/dist/schema/{assertType.d.ts → assert-type.d.ts} +1 -1
- package/dist/schema/assert-type.d.ts.map +1 -0
- package/dist/schema/base.d.ts +44 -150
- package/dist/schema/base.d.ts.map +1 -1
- package/dist/schema/{serwistConfigError.d.ts → error.d.ts} +3 -1
- package/dist/schema/error.d.ts.map +1 -0
- package/dist/schema/get-manifest.d.ts +72 -0
- package/dist/schema/get-manifest.d.ts.map +1 -0
- package/dist/schema/glob.d.ts +6 -26
- package/dist/schema/glob.d.ts.map +1 -1
- package/dist/schema/inject-manifest.d.ts +79 -0
- package/dist/schema/inject-manifest.d.ts.map +1 -0
- package/dist/schema/manifest-entry.d.ts +7 -0
- package/dist/schema/manifest-entry.d.ts.map +1 -0
- package/dist/schema/manifest-transform.d.ts +64 -0
- package/dist/schema/manifest-transform.d.ts.map +1 -0
- package/dist/schema/sw-dest.d.ts +8 -0
- package/dist/schema/sw-dest.d.ts.map +1 -0
- package/dist/schema/utils.d.ts +10 -0
- package/dist/schema/utils.d.ts.map +1 -0
- package/dist/types.d.ts +11 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.schema.ts +10 -8
- package/src/lib/transform-manifest.ts +0 -1
- package/src/lib/translate-url-to-sourcemap-paths.ts +3 -3
- package/src/lib/validate-options.ts +13 -6
- package/src/schema/base.ts +11 -13
- package/src/schema/error.ts +53 -0
- package/src/schema/{getManifest.ts → get-manifest.ts} +7 -6
- package/src/schema/glob.ts +14 -20
- package/src/schema/{injectManifest.ts → inject-manifest.ts} +13 -14
- package/src/schema/manifest-entry.ts +7 -0
- package/src/schema/manifest-transform.ts +17 -0
- package/src/schema/{swDest.ts → sw-dest.ts} +7 -11
- package/src/schema/utils.ts +27 -0
- package/src/types.ts +10 -4
- package/dist/chunks/getManifest.js +0 -6
- package/dist/chunks/injectManifest.js +0 -23
- package/dist/chunks/validationErrorMap.js +0 -54
- package/dist/schema/assertType.d.ts.map +0 -1
- package/dist/schema/getManifest.d.ts +0 -192
- package/dist/schema/getManifest.d.ts.map +0 -1
- package/dist/schema/injectManifest.d.ts +0 -213
- package/dist/schema/injectManifest.d.ts.map +0 -1
- package/dist/schema/manifestEntry.d.ts +0 -15
- package/dist/schema/manifestEntry.d.ts.map +0 -1
- package/dist/schema/manifestTransform.d.ts +0 -125
- package/dist/schema/manifestTransform.d.ts.map +0 -1
- package/dist/schema/serwistConfigError.d.ts.map +0 -1
- package/dist/schema/swDest.d.ts +0 -16
- package/dist/schema/swDest.d.ts.map +0 -1
- package/dist/schema/validationErrorMap.d.ts +0 -3
- package/dist/schema/validationErrorMap.d.ts.map +0 -1
- package/src/schema/manifestEntry.ts +0 -9
- package/src/schema/manifestTransform.ts +0 -15
- package/src/schema/serwistConfigError.ts +0 -6
- package/src/schema/validationErrorMap.ts +0 -36
- /package/src/schema/{assertType.ts → assert-type.ts} +0 -0
package/dist/schema/glob.d.ts
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const globPartial: z.ZodObject<{
|
|
3
3
|
globFollow: z.ZodDefault<z.ZodBoolean>;
|
|
4
|
-
globIgnores: z.ZodDefault<z.ZodArray<z.ZodString
|
|
5
|
-
globPatterns: z.ZodDefault<z.ZodArray<z.ZodString
|
|
4
|
+
globIgnores: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
5
|
+
globPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
6
6
|
globStrict: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
-
templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
8
|
-
},
|
|
9
|
-
globFollow: boolean;
|
|
10
|
-
globIgnores: string[];
|
|
11
|
-
globPatterns: string[];
|
|
12
|
-
globStrict: boolean;
|
|
13
|
-
templatedURLs?: Record<string, string | string[]> | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
globFollow?: boolean | undefined;
|
|
16
|
-
globIgnores?: string[] | undefined;
|
|
17
|
-
globPatterns?: string[] | undefined;
|
|
18
|
-
globStrict?: boolean | undefined;
|
|
19
|
-
templatedURLs?: Record<string, string | string[]> | undefined;
|
|
20
|
-
}>;
|
|
7
|
+
templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
8
|
+
}, z.core.$strict>;
|
|
21
9
|
export declare const optionalGlobDirectoryPartial: z.ZodObject<{
|
|
22
10
|
globDirectory: z.ZodOptional<z.ZodString>;
|
|
23
|
-
},
|
|
24
|
-
globDirectory?: string | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
globDirectory?: string | undefined;
|
|
27
|
-
}>;
|
|
11
|
+
}, z.core.$strict>;
|
|
28
12
|
export declare const requiredGlobDirectoryPartial: z.ZodObject<{
|
|
29
13
|
globDirectory: z.ZodString;
|
|
30
|
-
},
|
|
31
|
-
globDirectory: string;
|
|
32
|
-
}, {
|
|
33
|
-
globDirectory: string;
|
|
34
|
-
}>;
|
|
14
|
+
}, z.core.$strict>;
|
|
35
15
|
//# sourceMappingURL=glob.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/schema/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/schema/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,WAAW;;;;;;kBAMtB,CAAC;AAEH,eAAO,MAAM,4BAA4B;;kBAEvC,CAAC;AAIH,eAAO,MAAM,4BAA4B;;kBAEvC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const baseInjectPartial: z.ZodObject<{
|
|
3
|
+
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
4
|
+
swSrc: z.ZodString;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
export declare const injectManifestOptions: z.ZodObject<{
|
|
7
|
+
globDirectory: z.ZodString;
|
|
8
|
+
swDest: z.ZodString;
|
|
9
|
+
injectionPoint: z.ZodDefault<z.ZodString>;
|
|
10
|
+
swSrc: z.ZodString;
|
|
11
|
+
globFollow: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
+
globIgnores: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
13
|
+
globPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
14
|
+
globStrict: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
16
|
+
additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
17
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
18
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
url: z.ZodString;
|
|
20
|
+
}, z.core.$strict>]>>>;
|
|
21
|
+
disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
|
|
23
|
+
manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
24
|
+
size: z.ZodNumber;
|
|
25
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
26
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
29
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
30
|
+
size: z.ZodNumber;
|
|
31
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
32
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
url: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
37
|
+
size: z.ZodNumber;
|
|
38
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
39
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
url: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
42
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
43
|
+
size: z.ZodNumber;
|
|
44
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
45
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
url: z.ZodString;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
}, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
50
|
+
size: z.ZodNumber;
|
|
51
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
52
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
url: z.ZodString;
|
|
54
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
55
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
56
|
+
size: z.ZodNumber;
|
|
57
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
58
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
url: z.ZodString;
|
|
60
|
+
}, z.core.$strip>>;
|
|
61
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
63
|
+
size: z.ZodNumber;
|
|
64
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
65
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
url: z.ZodString;
|
|
67
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
68
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
69
|
+
size: z.ZodNumber;
|
|
70
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
71
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
+
url: z.ZodString;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
75
|
+
}, z.core.$strict>>>>>>;
|
|
76
|
+
maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
|
|
77
|
+
modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
//# sourceMappingURL=inject-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-manifest.d.ts","sourceRoot":"","sources":["../../src/schema/inject-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,iBAAiB;;;kBAG5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-entry.d.ts","sourceRoot":"","sources":["../../src/schema/manifest-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;kBAIxB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const manifestTransformResult: z.ZodObject<{
|
|
3
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
4
|
+
size: z.ZodNumber;
|
|
5
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
6
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export declare const manifestTransform: z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
12
|
+
size: z.ZodNumber;
|
|
13
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
14
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
url: z.ZodString;
|
|
16
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
17
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
18
|
+
size: z.ZodNumber;
|
|
19
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
20
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
url: z.ZodString;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
25
|
+
size: z.ZodNumber;
|
|
26
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
27
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
28
|
+
url: z.ZodString;
|
|
29
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
30
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
31
|
+
size: z.ZodNumber;
|
|
32
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
33
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
url: z.ZodString;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
}, z.core.$strict>>>, z.ZodTransform<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
38
|
+
size: z.ZodNumber;
|
|
39
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
40
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
url: z.ZodString;
|
|
42
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
43
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
44
|
+
size: z.ZodNumber;
|
|
45
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
46
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
url: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
}, z.core.$strict>>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
|
|
51
|
+
size: z.ZodNumber;
|
|
52
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
53
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
}, z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
|
|
56
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
57
|
+
size: z.ZodNumber;
|
|
58
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
59
|
+
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
url: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
}, z.core.$strict>>>>;
|
|
64
|
+
//# sourceMappingURL=manifest-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-transform.d.ts","sourceRoot":"","sources":["../../src/schema/manifest-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,uBAAuB;;;;;;;;kBAGlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAG5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const optionalSwDestPartial: z.ZodObject<{
|
|
3
|
+
swDest: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strict>;
|
|
5
|
+
export declare const requiredSwDestPartial: z.ZodObject<{
|
|
6
|
+
swDest: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
//# sourceMappingURL=sw-dest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sw-dest.d.ts","sourceRoot":"","sources":["../../src/schema/sw-dest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;kBAEhC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;kBAEhC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const fn: <TInput extends [z.ZodType, ...z.ZodType[]], TOutput extends z.ZodType>({ input, output }: {
|
|
3
|
+
input: TInput;
|
|
4
|
+
output: TOutput;
|
|
5
|
+
}) => z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionType<z.ZodTuple<TInput, null>, TOutput>, z.core.$InferInnerFunctionType<z.ZodTuple<TInput, null>, TOutput>>, z.ZodTransform<(...args: TInput extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...Prefix extends readonly [...infer Prefix extends z.core.SomeType[], infer Tail extends z.core.SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [.../*elided*/ any, (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k in keyof Prefix]: z.core.input<Prefix[k]>; } : [], (z.core.input<Tail> | undefined)?] : { [k_1 in keyof TInput]: z.core.input<TInput[k_1]>; } : []) => z.core.input<TOutput> extends z.core.output<TOutput> ? z.core.output<TOutput> & z.core.input<TOutput> : z.core.output<TOutput>, z.core.$InferInnerFunctionType<z.ZodTuple<TInput, null>, TOutput>>>;
|
|
6
|
+
export declare const asyncFn: <TInput extends [z.ZodType, ...z.ZodType[]], TOutput extends z.ZodType>({ input, output, }: {
|
|
7
|
+
input: TInput;
|
|
8
|
+
output: TOutput;
|
|
9
|
+
}) => z.ZodPipe<z.ZodCustom<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput>>, z.ZodTransform<Awaited<z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput> extends infer T ? T extends z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput> ? T extends z.core.$InferOuterFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput> ? T : z.core.$InferOuterFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput> : never : never>, z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<TInput, null>, TOutput>>>;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/schema/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,EAAE,GAAI,MAAM,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,SAAS,CAAC,CAAC,OAAO,EAAE,mBAAmB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,uiGAQ9I,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,MAAM,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,SAAS,CAAC,CAAC,OAAO,EAAE,oBAG5F;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB,umBAQA,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import type { Require } from "@serwist/utils";
|
|
1
|
+
import type { MaybePromise, Require } from "@serwist/utils";
|
|
2
2
|
import type { PackageJson } from "type-fest";
|
|
3
3
|
import type { z } from "zod";
|
|
4
|
-
import type { manifestEntry } from "./schema/
|
|
5
|
-
import type {
|
|
4
|
+
import type { manifestEntry } from "./schema/manifest-entry.js";
|
|
5
|
+
import type { manifestTransformResult } from "./schema/manifest-transform.js";
|
|
6
6
|
export type ManifestEntry = z.input<typeof manifestEntry>;
|
|
7
7
|
export type ManifestTransformResult = z.input<typeof manifestTransformResult>;
|
|
8
|
-
export type ManifestTransform =
|
|
8
|
+
export type ManifestTransform = (entries: (ManifestEntry & {
|
|
9
|
+
size: number;
|
|
10
|
+
})[], params?: unknown) => MaybePromise<{
|
|
11
|
+
manifest: (ManifestEntry & {
|
|
12
|
+
size: number;
|
|
13
|
+
})[];
|
|
14
|
+
warnings?: string[] | undefined;
|
|
15
|
+
}>;
|
|
9
16
|
export interface BasePartial {
|
|
10
17
|
/**
|
|
11
18
|
* A list of entries to be precached, in addition to any entries that are
|
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;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/build",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.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": [
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"glob": "10.4.5",
|
|
53
53
|
"pretty-bytes": "6.1.1",
|
|
54
54
|
"source-map": "0.8.0-beta.0",
|
|
55
|
-
"zod": "
|
|
55
|
+
"zod": "4.0.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/common-tags": "1.8.4",
|
|
59
|
-
"@types/node": "24.0.
|
|
60
|
-
"rollup": "4.
|
|
59
|
+
"@types/node": "24.0.14",
|
|
60
|
+
"rollup": "4.45.1",
|
|
61
61
|
"type-fest": "4.41.0",
|
|
62
62
|
"typescript": "5.8.3",
|
|
63
|
-
"@serwist/configs": "9.0
|
|
64
|
-
"@serwist/utils": "9.0
|
|
63
|
+
"@serwist/configs": "9.1.0",
|
|
64
|
+
"@serwist/utils": "9.1.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"typescript": ">=5.0.0"
|
package/src/index.schema.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { type Assignable, type Equals, assertType } from "./schema/
|
|
1
|
+
import { type Assignable, type Equals, assertType } from "./schema/assert-type.js";
|
|
2
2
|
import { basePartial } from "./schema/base.js";
|
|
3
|
-
import { getManifestOptions } from "./schema/
|
|
3
|
+
import { getManifestOptions } from "./schema/get-manifest.js";
|
|
4
4
|
import { globPartial, optionalGlobDirectoryPartial, requiredGlobDirectoryPartial } from "./schema/glob.js";
|
|
5
|
-
import { baseInjectPartial, injectManifestOptions } from "./schema/
|
|
6
|
-
import { manifestEntry } from "./schema/
|
|
7
|
-
import { manifestTransform, manifestTransformResult } from "./schema/
|
|
8
|
-
import { SerwistConfigError } from "./schema/
|
|
9
|
-
import { optionalSwDestPartial, requiredSwDestPartial } from "./schema/
|
|
10
|
-
import {
|
|
5
|
+
import { baseInjectPartial, injectManifestOptions } from "./schema/inject-manifest.js";
|
|
6
|
+
import { manifestEntry } from "./schema/manifest-entry.js";
|
|
7
|
+
import { manifestTransform, manifestTransformResult } from "./schema/manifest-transform.js";
|
|
8
|
+
import { SerwistConfigError, validationErrorMap } from "./schema/error.js";
|
|
9
|
+
import { optionalSwDestPartial, requiredSwDestPartial } from "./schema/sw-dest.js";
|
|
10
|
+
import { fn, asyncFn } from "./schema/utils.js";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
assertType,
|
|
14
|
+
fn,
|
|
15
|
+
asyncFn,
|
|
14
16
|
basePartial,
|
|
15
17
|
globPartial,
|
|
16
18
|
baseInjectPartial as injectPartial,
|
|
@@ -155,7 +155,6 @@ export async function transformManifest({
|
|
|
155
155
|
let size = 0;
|
|
156
156
|
for (const manifestEntry of transformedManifest as (ManifestEntry & { size?: number })[]) {
|
|
157
157
|
size += manifestEntry.size || 0;
|
|
158
|
-
// biome-ignore lint/performance/noDelete: These values are no longer necessary.
|
|
159
158
|
delete manifestEntry.size;
|
|
160
159
|
}
|
|
161
160
|
|
|
@@ -19,9 +19,9 @@ export function translateURLToSourcemapPaths(
|
|
|
19
19
|
srcPath: string | undefined;
|
|
20
20
|
warning: string | undefined;
|
|
21
21
|
} {
|
|
22
|
-
let destPath: string | undefined
|
|
23
|
-
let srcPath: string | undefined
|
|
24
|
-
let warning: string | undefined
|
|
22
|
+
let destPath: string | undefined;
|
|
23
|
+
let srcPath: string | undefined;
|
|
24
|
+
let warning: string | undefined;
|
|
25
25
|
|
|
26
26
|
if (url && !url.startsWith("data:")) {
|
|
27
27
|
const possibleSrcPath = path.resolve(path.dirname(swSrc), url);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SerwistConfigError } from "../schema/error.js";
|
|
2
3
|
/*
|
|
3
4
|
Copyright 2021 Google LLC
|
|
4
5
|
|
|
@@ -6,21 +7,27 @@ import { SerwistConfigError } from "../schema/serwistConfigError.js";
|
|
|
6
7
|
license that can be found in the LICENSE file or at
|
|
7
8
|
https://opensource.org/licenses/MIT.
|
|
8
9
|
*/
|
|
9
|
-
import { validationErrorMap } from "../schema/
|
|
10
|
+
import { validationErrorMap } from "../schema/error.js";
|
|
10
11
|
import type { GetManifestOptionsComplete, InjectManifestOptionsComplete } from "../types.js";
|
|
11
12
|
|
|
12
13
|
export const validateGetManifestOptions = async (input: unknown): Promise<GetManifestOptionsComplete> => {
|
|
13
|
-
const result = await (await import("../schema/
|
|
14
|
+
const result = await (await import("../schema/get-manifest.js")).getManifestOptions.spa(input, { error: validationErrorMap });
|
|
14
15
|
if (!result.success) {
|
|
15
|
-
throw new SerwistConfigError({
|
|
16
|
+
throw new SerwistConfigError({
|
|
17
|
+
moduleName: "@serwist/build",
|
|
18
|
+
message: z.prettifyError(result.error),
|
|
19
|
+
});
|
|
16
20
|
}
|
|
17
21
|
return result.data;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export const validateInjectManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {
|
|
21
|
-
const result = await (await import("../schema/
|
|
25
|
+
const result = await (await import("../schema/inject-manifest.js")).injectManifestOptions.spa(input, { error: validationErrorMap });
|
|
22
26
|
if (!result.success) {
|
|
23
|
-
throw new SerwistConfigError({
|
|
27
|
+
throw new SerwistConfigError({
|
|
28
|
+
moduleName: "@serwist/build",
|
|
29
|
+
message: z.prettifyError(result.error),
|
|
30
|
+
});
|
|
24
31
|
}
|
|
25
32
|
return result.data;
|
|
26
33
|
};
|
package/src/schema/base.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
import type { BasePartial, BaseResolved } from "../types.js";
|
|
4
|
-
import { type Equals, assertType } from "./
|
|
5
|
-
import { manifestEntry } from "./
|
|
6
|
-
import { manifestTransform } from "./
|
|
4
|
+
import { type Equals, assertType } from "./assert-type.js";
|
|
5
|
+
import { manifestEntry } from "./manifest-entry.js";
|
|
6
|
+
import { manifestTransform } from "./manifest-transform.js";
|
|
7
7
|
|
|
8
|
-
export const basePartial = z
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
.strict("Do not pass invalid properties to BasePartial!");
|
|
8
|
+
export const basePartial = z.strictObject({
|
|
9
|
+
additionalPrecacheEntries: z.array(z.union([z.string(), manifestEntry])).optional(),
|
|
10
|
+
disablePrecacheManifest: z.boolean().default(false),
|
|
11
|
+
dontCacheBustURLsMatching: z.instanceof(RegExp).optional(),
|
|
12
|
+
manifestTransforms: z.array(manifestTransform).optional(),
|
|
13
|
+
maximumFileSizeToCacheInBytes: z.number().default(2097152),
|
|
14
|
+
modifyURLPrefix: z.record(z.string(), z.string()).optional(),
|
|
15
|
+
});
|
|
18
16
|
|
|
19
17
|
assertType<Equals<BasePartial, z.input<typeof basePartial>>>();
|
|
20
18
|
assertType<Equals<BaseResolved, z.output<typeof basePartial>>>();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export class SerwistConfigError extends Error {
|
|
4
|
+
constructor({ moduleName, message }: { moduleName?: string; message?: string }) {
|
|
5
|
+
super(`Invalid ${moduleName ?? "Serwist"} configuration:\n${message}`);
|
|
6
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const parsedType = (data: any): string => {
|
|
11
|
+
const t = typeof data;
|
|
12
|
+
|
|
13
|
+
switch (t) {
|
|
14
|
+
case "number": {
|
|
15
|
+
return Number.isNaN(data) ? "NaN" : "number";
|
|
16
|
+
}
|
|
17
|
+
case "object": {
|
|
18
|
+
if (Array.isArray(data)) {
|
|
19
|
+
return "array";
|
|
20
|
+
}
|
|
21
|
+
if (data === null) {
|
|
22
|
+
return "null";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
26
|
+
return data.constructor.name;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const validationErrorMap: z.core.$ZodErrorMap = (error) => {
|
|
34
|
+
/* This is where you override the various error codes */
|
|
35
|
+
switch (error.code) {
|
|
36
|
+
case "invalid_type": {
|
|
37
|
+
return `${error.message ?? "Received invalid type"}: expected ${error.expected}, received ${parsedType(error.input)}.`;
|
|
38
|
+
}
|
|
39
|
+
case "invalid_value": {
|
|
40
|
+
return `${error.message ?? "Received invalid value"}: expected ${error.expected}, received ${parsedType(error.input)}.`;
|
|
41
|
+
}
|
|
42
|
+
case "invalid_union": {
|
|
43
|
+
return `${error.message ?? "Received invalid union"}:\n${error.errors.flatMap((err) => err.map((e) => ` → ${e.message}`)).join("\n")}`;
|
|
44
|
+
}
|
|
45
|
+
case "unrecognized_keys": {
|
|
46
|
+
return `${error.message ?? "Received unrecognized keys"}: ${error.keys.join(".")}`;
|
|
47
|
+
}
|
|
48
|
+
case "custom": {
|
|
49
|
+
return error.message ?? undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import type { GetManifestOptions, GetManifestOptionsComplete } from "../types.js";
|
|
3
|
-
import { type Equals, assertType } from "./
|
|
3
|
+
import { type Equals, assertType } from "./assert-type.js";
|
|
4
4
|
import { basePartial } from "./base.js";
|
|
5
5
|
import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
|
|
6
6
|
|
|
7
|
-
export const getManifestOptions =
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
.
|
|
7
|
+
export const getManifestOptions = z.strictObject({
|
|
8
|
+
...basePartial.shape,
|
|
9
|
+
...globPartial.shape,
|
|
10
|
+
...requiredGlobDirectoryPartial.shape,
|
|
11
|
+
});
|
|
11
12
|
|
|
12
13
|
assertType<Equals<GetManifestOptions, z.input<typeof getManifestOptions>>>();
|
|
13
14
|
assertType<Equals<GetManifestOptionsComplete, z.output<typeof getManifestOptions>>>();
|
package/src/schema/glob.ts
CHANGED
|
@@ -7,31 +7,25 @@ import type {
|
|
|
7
7
|
RequiredGlobDirectoryPartial,
|
|
8
8
|
RequiredGlobDirectoryResolved,
|
|
9
9
|
} from "../types.js";
|
|
10
|
-
import { type Equals, assertType } from "./
|
|
10
|
+
import { type Equals, assertType } from "./assert-type.js";
|
|
11
11
|
|
|
12
|
-
export const globPartial = z
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
.strict("Do not pass invalid properties to GlobPartial!");
|
|
12
|
+
export const globPartial = z.strictObject({
|
|
13
|
+
globFollow: z.boolean().default(true),
|
|
14
|
+
globIgnores: z.array(z.string()).default(["**/node_modules/**/*"]),
|
|
15
|
+
globPatterns: z.array(z.string()).default(["**/*.{js,css,html}"]),
|
|
16
|
+
globStrict: z.boolean().default(true),
|
|
17
|
+
templatedURLs: z.record(z.string(), z.union([z.string(), z.array(z.string())])).optional(),
|
|
18
|
+
});
|
|
21
19
|
|
|
22
|
-
export const optionalGlobDirectoryPartial = z
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
.strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!");
|
|
20
|
+
export const optionalGlobDirectoryPartial = z.strictObject({
|
|
21
|
+
globDirectory: z.string().optional(),
|
|
22
|
+
});
|
|
27
23
|
|
|
28
24
|
// This needs to be set when using GetManifest or InjectManifest. This is
|
|
29
25
|
// enforced via runtime validation, and needs to be documented.
|
|
30
|
-
export const requiredGlobDirectoryPartial = z
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
.strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!");
|
|
26
|
+
export const requiredGlobDirectoryPartial = z.strictObject({
|
|
27
|
+
globDirectory: z.string(),
|
|
28
|
+
});
|
|
35
29
|
|
|
36
30
|
assertType<Equals<GlobPartial, z.input<typeof globPartial>>>();
|
|
37
31
|
assertType<Equals<GlobResolved, z.output<typeof globPartial>>>();
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "../types.js";
|
|
3
|
-
import { type Equals, assertType } from "./
|
|
3
|
+
import { type Equals, assertType } from "./assert-type.js";
|
|
4
4
|
import { basePartial } from "./base.js";
|
|
5
5
|
import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
|
|
6
|
-
import { requiredSwDestPartial } from "./
|
|
6
|
+
import { requiredSwDestPartial } from "./sw-dest.js";
|
|
7
7
|
|
|
8
|
-
export const baseInjectPartial = z
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
.strict("Do not pass invalid properties to InjectPartial!");
|
|
8
|
+
export const baseInjectPartial = z.strictObject({
|
|
9
|
+
injectionPoint: z.string().default("self.__SW_MANIFEST"),
|
|
10
|
+
swSrc: z.string(),
|
|
11
|
+
});
|
|
14
12
|
|
|
15
|
-
export const injectManifestOptions =
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
13
|
+
export const injectManifestOptions = z.strictObject({
|
|
14
|
+
...basePartial.shape,
|
|
15
|
+
...globPartial.shape,
|
|
16
|
+
...baseInjectPartial.shape,
|
|
17
|
+
...requiredSwDestPartial.shape,
|
|
18
|
+
...requiredGlobDirectoryPartial.shape,
|
|
19
|
+
});
|
|
21
20
|
|
|
22
21
|
assertType<Equals<InjectPartial, z.input<typeof baseInjectPartial>>>();
|
|
23
22
|
assertType<Equals<InjectResolved, z.output<typeof baseInjectPartial>>>();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { manifestEntry } from "./manifest-entry.js";
|
|
3
|
+
import { asyncFn } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
const sizeObject = z.object({ size: z.number() });
|
|
6
|
+
|
|
7
|
+
const manifestEntryWithSize = z.object({ ...manifestEntry.shape, ...sizeObject.shape });
|
|
8
|
+
|
|
9
|
+
export const manifestTransformResult = z.strictObject({
|
|
10
|
+
manifest: z.array(manifestEntryWithSize),
|
|
11
|
+
warnings: z.array(z.string()).optional(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const manifestTransform = asyncFn({
|
|
15
|
+
input: [z.array(manifestEntryWithSize), z.unknown().optional()],
|
|
16
|
+
output: manifestTransformResult,
|
|
17
|
+
});
|