@serwist/build 10.0.0-preview.8 → 10.0.0-preview.9

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 (69) hide show
  1. package/dist/chunks/constants.js +34 -33
  2. package/dist/chunks/get-manifest.js +11 -0
  3. package/dist/chunks/glob.js +43 -25
  4. package/dist/chunks/inject-manifest.js +29 -0
  5. package/dist/index.js +10 -10
  6. package/dist/index.schema.d.ts +9 -9
  7. package/dist/index.schema.d.ts.map +1 -1
  8. package/dist/index.schema.js +3 -3
  9. package/dist/lib/transform-manifest.d.ts.map +1 -1
  10. package/dist/lib/validate-options.d.ts.map +1 -1
  11. package/dist/schema/{assertType.d.ts → assert-type.d.ts} +1 -1
  12. package/dist/schema/assert-type.d.ts.map +1 -0
  13. package/dist/schema/base.d.ts +44 -150
  14. package/dist/schema/base.d.ts.map +1 -1
  15. package/dist/schema/{serwistConfigError.d.ts → error.d.ts} +3 -1
  16. package/dist/schema/error.d.ts.map +1 -0
  17. package/dist/schema/get-manifest.d.ts +72 -0
  18. package/dist/schema/get-manifest.d.ts.map +1 -0
  19. package/dist/schema/glob.d.ts +6 -26
  20. package/dist/schema/glob.d.ts.map +1 -1
  21. package/dist/schema/inject-manifest.d.ts +79 -0
  22. package/dist/schema/inject-manifest.d.ts.map +1 -0
  23. package/dist/schema/manifest-entry.d.ts +7 -0
  24. package/dist/schema/manifest-entry.d.ts.map +1 -0
  25. package/dist/schema/manifest-transform.d.ts +64 -0
  26. package/dist/schema/manifest-transform.d.ts.map +1 -0
  27. package/dist/schema/sw-dest.d.ts +8 -0
  28. package/dist/schema/sw-dest.d.ts.map +1 -0
  29. package/dist/schema/utils.d.ts +10 -0
  30. package/dist/schema/utils.d.ts.map +1 -0
  31. package/dist/types.d.ts +11 -4
  32. package/dist/types.d.ts.map +1 -1
  33. package/package.json +11 -9
  34. package/src/index.schema.ts +10 -8
  35. package/src/lib/transform-manifest.ts +0 -1
  36. package/src/lib/translate-url-to-sourcemap-paths.ts +3 -3
  37. package/src/lib/validate-options.ts +12 -6
  38. package/src/schema/base.ts +11 -13
  39. package/src/schema/error.ts +53 -0
  40. package/src/schema/{getManifest.ts → get-manifest.ts} +7 -6
  41. package/src/schema/glob.ts +15 -21
  42. package/src/schema/inject-manifest.ts +24 -0
  43. package/src/schema/manifest-entry.ts +7 -0
  44. package/src/schema/manifest-transform.ts +17 -0
  45. package/src/schema/{swDest.ts → sw-dest.ts} +7 -11
  46. package/src/schema/utils.ts +27 -0
  47. package/src/types.ts +10 -4
  48. package/dist/chunks/getManifest.js +0 -7
  49. package/dist/chunks/injectManifest.js +0 -23
  50. package/dist/schema/assertType.d.ts.map +0 -1
  51. package/dist/schema/getManifest.d.ts +0 -192
  52. package/dist/schema/getManifest.d.ts.map +0 -1
  53. package/dist/schema/injectManifest.d.ts +0 -213
  54. package/dist/schema/injectManifest.d.ts.map +0 -1
  55. package/dist/schema/manifestEntry.d.ts +0 -15
  56. package/dist/schema/manifestEntry.d.ts.map +0 -1
  57. package/dist/schema/manifestTransform.d.ts +0 -125
  58. package/dist/schema/manifestTransform.d.ts.map +0 -1
  59. package/dist/schema/serwistConfigError.d.ts.map +0 -1
  60. package/dist/schema/swDest.d.ts +0 -16
  61. package/dist/schema/swDest.d.ts.map +0 -1
  62. package/dist/schema/validationErrorMap.d.ts +0 -3
  63. package/dist/schema/validationErrorMap.d.ts.map +0 -1
  64. package/src/schema/injectManifest.ts +0 -25
  65. package/src/schema/manifestEntry.ts +0 -9
  66. package/src/schema/manifestTransform.ts +0 -15
  67. package/src/schema/serwistConfigError.ts +0 -6
  68. package/src/schema/validationErrorMap.ts +0 -36
  69. /package/src/schema/{assertType.ts → assert-type.ts} +0 -0
@@ -1,125 +0,0 @@
1
- import { z } from "zod";
2
- export declare const manifestTransformResult: z.ZodObject<{
3
- manifest: z.ZodArray<z.ZodObject<{
4
- integrity: z.ZodOptional<z.ZodString>;
5
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
- url: z.ZodString;
7
- } & {
8
- size: z.ZodNumber;
9
- }, "strip", z.ZodTypeAny, {
10
- url: string;
11
- size: number;
12
- integrity?: string | undefined;
13
- revision?: string | null | undefined;
14
- }, {
15
- url: string;
16
- size: number;
17
- integrity?: string | undefined;
18
- revision?: string | null | undefined;
19
- }>, "many">;
20
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
21
- }, "strict", z.ZodTypeAny, {
22
- manifest: {
23
- url: string;
24
- size: number;
25
- integrity?: string | undefined;
26
- revision?: string | null | undefined;
27
- }[];
28
- warnings?: string[] | undefined;
29
- }, {
30
- manifest: {
31
- url: string;
32
- size: number;
33
- integrity?: string | undefined;
34
- revision?: string | null | undefined;
35
- }[];
36
- warnings?: string[] | undefined;
37
- }>;
38
- export declare const manifestTransform: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
39
- integrity: z.ZodOptional<z.ZodString>;
40
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
- url: z.ZodString;
42
- } & {
43
- size: z.ZodNumber;
44
- }, "strip", z.ZodTypeAny, {
45
- url: string;
46
- size: number;
47
- integrity?: string | undefined;
48
- revision?: string | null | undefined;
49
- }, {
50
- url: string;
51
- size: number;
52
- integrity?: string | undefined;
53
- revision?: string | null | undefined;
54
- }>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
55
- manifest: z.ZodArray<z.ZodObject<{
56
- integrity: z.ZodOptional<z.ZodString>;
57
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
- url: z.ZodString;
59
- } & {
60
- size: z.ZodNumber;
61
- }, "strip", z.ZodTypeAny, {
62
- url: string;
63
- size: number;
64
- integrity?: string | undefined;
65
- revision?: string | null | undefined;
66
- }, {
67
- url: string;
68
- size: number;
69
- integrity?: string | undefined;
70
- revision?: string | null | undefined;
71
- }>, "many">;
72
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
- }, "strict", z.ZodTypeAny, {
74
- manifest: {
75
- url: string;
76
- size: number;
77
- integrity?: string | undefined;
78
- revision?: string | null | undefined;
79
- }[];
80
- warnings?: string[] | undefined;
81
- }, {
82
- manifest: {
83
- url: string;
84
- size: number;
85
- integrity?: string | undefined;
86
- revision?: string | null | undefined;
87
- }[];
88
- warnings?: string[] | undefined;
89
- }>>, z.ZodObject<{
90
- manifest: z.ZodArray<z.ZodObject<{
91
- integrity: z.ZodOptional<z.ZodString>;
92
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
- url: z.ZodString;
94
- } & {
95
- size: z.ZodNumber;
96
- }, "strip", z.ZodTypeAny, {
97
- url: string;
98
- size: number;
99
- integrity?: string | undefined;
100
- revision?: string | null | undefined;
101
- }, {
102
- url: string;
103
- size: number;
104
- integrity?: string | undefined;
105
- revision?: string | null | undefined;
106
- }>, "many">;
107
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
108
- }, "strict", z.ZodTypeAny, {
109
- manifest: {
110
- url: string;
111
- size: number;
112
- integrity?: string | undefined;
113
- revision?: string | null | undefined;
114
- }[];
115
- warnings?: string[] | undefined;
116
- }, {
117
- manifest: {
118
- url: string;
119
- size: number;
120
- integrity?: string | undefined;
121
- revision?: string | null | undefined;
122
- }[];
123
- warnings?: string[] | undefined;
124
- }>]>>;
125
- //# sourceMappingURL=manifestTransform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manifestTransform.d.ts","sourceRoot":"","sources":["../../src/schema/manifestTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKmC,CAAC;AAExE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAG7B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"serwistConfigError.d.ts","sourceRoot":"","sources":["../../src/schema/serwistConfigError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAI/E"}
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- export declare const optionalSwDestPartial: z.ZodObject<{
3
- swDest: z.ZodOptional<z.ZodString>;
4
- }, "strict", z.ZodTypeAny, {
5
- swDest?: string | undefined;
6
- }, {
7
- swDest?: string | undefined;
8
- }>;
9
- export declare const requiredSwDestPartial: z.ZodObject<{
10
- swDest: z.ZodString;
11
- }, "strict", z.ZodTypeAny, {
12
- swDest: string;
13
- }, {
14
- swDest: string;
15
- }>;
16
- //# sourceMappingURL=swDest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swDest.d.ts","sourceRoot":"","sources":["../../src/schema/swDest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;EAI4B,CAAC;AAE/D,eAAO,MAAM,qBAAqB;;;;;;EAI4B,CAAC"}
@@ -1,3 +0,0 @@
1
- import { z } from "zod";
2
- export declare const validationErrorMap: z.ZodErrorMap;
3
- //# sourceMappingURL=validationErrorMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validationErrorMap.d.ts","sourceRoot":"","sources":["../../src/schema/validationErrorMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,WAiClC,CAAC"}
@@ -1,25 +0,0 @@
1
- import { z } from "zod";
2
- import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "../types.js";
3
- import { type Equals, assertType } from "./assertType.js";
4
- import { basePartial } from "./base.js";
5
- import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
6
- import { requiredSwDestPartial } from "./swDest.js";
7
-
8
- export const baseInjectPartial = z
9
- .object({
10
- injectionPoint: z.string().min(1, "`injectionPoint` must not be empty!").default("self.__SW_MANIFEST"),
11
- swSrc: z.string().min(1, "`swSrc` must not be empty!"),
12
- })
13
- .strict("Do not pass invalid properties to InjectPartial!");
14
-
15
- export const injectManifestOptions = basePartial
16
- .merge(globPartial)
17
- .merge(baseInjectPartial)
18
- .merge(requiredSwDestPartial)
19
- .merge(requiredGlobDirectoryPartial)
20
- .strict("Do not pass invalid properties to InjectManifestOptions!");
21
-
22
- assertType<Equals<InjectPartial, z.input<typeof baseInjectPartial>>>();
23
- assertType<Equals<InjectResolved, z.output<typeof baseInjectPartial>>>();
24
- assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();
25
- assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();
@@ -1,9 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const manifestEntry = z
4
- .object({
5
- integrity: z.string().optional(),
6
- revision: z.string().nullable().optional(),
7
- url: z.string(),
8
- })
9
- .strict("Do not pass invalid properties to ManifestEntry!");
@@ -1,15 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { manifestEntry } from "./manifestEntry.js";
4
-
5
- export const manifestTransformResult = z
6
- .object({
7
- manifest: z.array(manifestEntry.merge(z.object({ size: z.number() }))),
8
- warnings: z.array(z.string()).optional(),
9
- })
10
- .strict("Do not pass invalid properties to ManifestTransformResult!");
11
-
12
- export const manifestTransform = z.function(
13
- z.tuple([z.array(manifestEntry.merge(z.object({ size: z.number() }))), z.unknown().optional()]),
14
- z.union([z.promise(manifestTransformResult), manifestTransformResult]),
15
- );
@@ -1,6 +0,0 @@
1
- export class SerwistConfigError extends Error {
2
- constructor({ moduleName, message }: { moduleName?: string; message?: string }) {
3
- super(`Received an invalid ${moduleName ?? "Serwist"} configuration: ${message}`);
4
- Object.setPrototypeOf(this, new.target.prototype);
5
- }
6
- }
@@ -1,36 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const validationErrorMap: z.ZodErrorMap = (error, ctx) => {
4
- /*
5
- This is where you override the various error codes
6
- */
7
- switch (error.code) {
8
- case z.ZodIssueCode.invalid_type: {
9
- return { message: `${error.message ?? "Received invalid type"}: expected ${error.expected}, received ${error.received}.` };
10
- }
11
- case z.ZodIssueCode.invalid_literal: {
12
- return { message: `${error.message ?? "Received invalid literal"}: expected ${error.expected}, received ${error.received}.` };
13
- }
14
- case z.ZodIssueCode.unrecognized_keys: {
15
- return { message: `${error.message ?? "Received unrecognized keys"}: ${error.keys.join(",")}` };
16
- }
17
- case z.ZodIssueCode.invalid_arguments: {
18
- return {
19
- message: `${error.message ?? "Received invalid arguments"}: ${error.argumentsError.errors.map((e) => validationErrorMap(e, ctx)).join(",")}.`,
20
- };
21
- }
22
- case z.ZodIssueCode.invalid_return_type: {
23
- return {
24
- message: `${error.message ?? "Received invalid return type"}: ${error.returnTypeError.errors
25
- .map((e) => validationErrorMap(e, ctx))
26
- .join(",")}.`,
27
- };
28
- }
29
- case z.ZodIssueCode.custom: {
30
- return { message: error.message ?? ctx.defaultError };
31
- }
32
- }
33
-
34
- // Fallback to the default message.
35
- return { message: ctx.defaultError };
36
- };
File without changes