@serwist/build 8.4.4 → 9.0.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/getManifest.js +6 -0
- package/dist/chunks/glob.js +60 -0
- package/dist/chunks/injectManifest.js +23 -0
- package/dist/chunks/serwist-config-error.js +57 -0
- package/dist/chunks/vite.js +7 -0
- package/dist/chunks/webpack.js +34 -0
- package/dist/get-manifest.d.ts +2 -1
- package/dist/get-manifest.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -813
- package/dist/index.next.d.ts +3 -0
- package/dist/index.next.d.ts.map +1 -0
- package/dist/index.next.js +35 -0
- package/dist/inject-manifest.d.ts +2 -1
- package/dist/inject-manifest.d.ts.map +1 -0
- package/dist/lib/additional-precache-entries-transform.d.ts +6 -5
- package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -0
- package/dist/lib/errors.d.ts +1 -2
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/escape-regexp.d.ts +2 -1
- package/dist/lib/escape-regexp.d.ts.map +1 -0
- package/dist/lib/get-composite-details.d.ts +2 -1
- package/dist/lib/get-composite-details.d.ts.map +1 -0
- package/dist/lib/get-file-details.d.ts +2 -1
- package/dist/lib/get-file-details.d.ts.map +1 -0
- package/dist/lib/get-file-hash.d.ts +1 -0
- package/dist/lib/get-file-hash.d.ts.map +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts +1 -0
- package/dist/lib/get-file-manifest-entries.d.ts.map +1 -0
- package/dist/lib/get-file-size.d.ts +1 -0
- package/dist/lib/get-file-size.d.ts.map +1 -0
- package/dist/lib/get-source-map-url.d.ts +1 -0
- package/dist/lib/get-source-map-url.d.ts.map +1 -0
- package/dist/lib/get-string-details.d.ts +1 -0
- package/dist/lib/get-string-details.d.ts.map +1 -0
- package/dist/lib/get-string-hash.d.ts +1 -0
- package/dist/lib/get-string-hash.d.ts.map +1 -0
- package/dist/lib/maximum-size-transform.d.ts +1 -0
- package/dist/lib/maximum-size-transform.d.ts.map +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts +1 -0
- package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts +1 -0
- package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -0
- package/dist/lib/rebase-path.d.ts +1 -0
- package/dist/lib/rebase-path.d.ts.map +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts +1 -0
- package/dist/lib/replace-and-update-source-map.d.ts.map +1 -0
- package/dist/lib/serwist-config-error.d.ts +7 -0
- package/dist/lib/serwist-config-error.d.ts.map +1 -0
- package/dist/lib/transform-manifest.d.ts +2 -1
- package/dist/lib/transform-manifest.d.ts.map +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts +1 -0
- package/dist/lib/translate-url-to-sourcemap-paths.d.ts.map +1 -0
- package/dist/lib/validate-next-options.d.ts +3 -0
- package/dist/lib/validate-next-options.d.ts.map +1 -0
- package/dist/lib/validate-options.d.ts +6 -8
- package/dist/lib/validate-options.d.ts.map +1 -0
- package/dist/schema/base.d.ts +169 -0
- package/dist/schema/base.d.ts.map +1 -0
- package/dist/schema/getManifest.d.ts +187 -0
- package/dist/schema/getManifest.d.ts.map +1 -0
- package/dist/schema/glob.d.ts +35 -0
- package/dist/schema/glob.d.ts.map +1 -0
- package/dist/schema/injectManifest.d.ts +206 -0
- package/dist/schema/injectManifest.d.ts.map +1 -0
- package/dist/schema/manifestEntry.d.ts +15 -0
- package/dist/schema/manifestEntry.d.ts.map +1 -0
- package/dist/schema/manifestTransform.d.ts +121 -0
- package/dist/schema/manifestTransform.d.ts.map +1 -0
- package/dist/schema/next.d.ts +243 -0
- package/dist/schema/next.d.ts.map +1 -0
- package/dist/schema/swDest.d.ts +16 -0
- package/dist/schema/swDest.d.ts.map +1 -0
- package/dist/schema/validationErrorMap.d.ts +3 -0
- package/dist/schema/validationErrorMap.d.ts.map +1 -0
- package/dist/schema/vite.d.ts +196 -0
- package/dist/schema/vite.d.ts.map +1 -0
- package/dist/schema/webpack.d.ts +231 -0
- package/dist/schema/webpack.d.ts.map +1 -0
- package/dist/types.d.ts +147 -175
- package/dist/types.d.ts.map +1 -0
- package/package.json +42 -28
- package/src/_types.js +112 -0
- package/src/get-manifest.ts +33 -0
- package/src/index.next.ts +3 -0
- package/{dist/index.d.cts → src/index.ts} +27 -2
- package/src/inject-manifest.ts +140 -0
- package/src/lib/additional-precache-entries-transform.ts +58 -0
- package/src/lib/errors.ts +99 -0
- package/src/lib/escape-regexp.ts +12 -0
- package/src/lib/get-composite-details.ts +31 -0
- package/src/lib/get-file-details.ts +68 -0
- package/src/lib/get-file-hash.ts +21 -0
- package/src/lib/get-file-manifest-entries.ts +126 -0
- package/src/lib/get-file-size.ts +23 -0
- package/src/lib/get-source-map-url.ts +17 -0
- package/src/lib/get-string-details.ts +18 -0
- package/src/lib/get-string-hash.ts +15 -0
- package/src/lib/maximum-size-transform.ts +29 -0
- package/src/lib/modify-url-prefix-transform.ts +55 -0
- package/src/lib/no-revision-for-urls-matching-transform.ts +32 -0
- package/src/lib/rebase-path.ts +22 -0
- package/src/lib/replace-and-update-source-map.ts +122 -0
- package/src/lib/serwist-config-error.ts +6 -0
- package/src/lib/transform-manifest.ts +158 -0
- package/src/lib/translate-url-to-sourcemap-paths.ts +38 -0
- package/src/lib/validate-next-options.ts +14 -0
- package/src/lib/validate-options.ts +47 -0
- package/src/schema/base.ts +16 -0
- package/src/schema/getManifest.ts +14 -0
- package/src/schema/glob.ts +41 -0
- package/src/schema/injectManifest.ts +23 -0
- package/src/schema/manifestEntry.ts +9 -0
- package/src/schema/manifestTransform.ts +15 -0
- package/src/schema/next.ts +35 -0
- package/src/schema/swDest.ts +14 -0
- package/src/schema/validationErrorMap.ts +36 -0
- package/src/schema/vite.ts +18 -0
- package/src/schema/webpack.ts +47 -0
- package/src/types.ts +407 -0
- package/dist/index.cjs +0 -1632
- package/dist/lib/cdn-utils.d.ts +0 -1
- package/dist/lib/copy-serwist-libraries.d.ts +0 -16
- package/dist/schema/index.d.ts +0 -605
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { b as basePartial, g as globPartial, r as requiredGlobDirectoryPartial } from './glob.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
const getManifestOptions = basePartial.merge(globPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to GetManifestOptions!");
|
|
5
|
+
|
|
6
|
+
export { getManifestOptions };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const manifestEntry = z.object({
|
|
4
|
+
integrity: z.string().optional(),
|
|
5
|
+
revision: z.string().nullable(),
|
|
6
|
+
url: z.string()
|
|
7
|
+
}).strict("Do not pass invalid properties to ManifestEntry!");
|
|
8
|
+
|
|
9
|
+
const manifestTransformResult = z.object({
|
|
10
|
+
manifest: z.array(manifestEntry.merge(z.object({
|
|
11
|
+
size: z.number()
|
|
12
|
+
}))),
|
|
13
|
+
warnings: z.array(z.string()).optional()
|
|
14
|
+
}).strict("Do not pass invalid properties to ManifestTransformResult!");
|
|
15
|
+
const manifestTransform = z.function(z.tuple([
|
|
16
|
+
z.array(manifestEntry.merge(z.object({
|
|
17
|
+
size: z.number()
|
|
18
|
+
}))),
|
|
19
|
+
z.unknown().optional()
|
|
20
|
+
]), z.union([
|
|
21
|
+
z.promise(manifestTransformResult),
|
|
22
|
+
manifestTransformResult
|
|
23
|
+
]));
|
|
24
|
+
|
|
25
|
+
const basePartial = z.object({
|
|
26
|
+
additionalPrecacheEntries: z.array(z.union([
|
|
27
|
+
z.string(),
|
|
28
|
+
manifestEntry
|
|
29
|
+
])).optional(),
|
|
30
|
+
disablePrecacheManifest: z.boolean().default(false),
|
|
31
|
+
dontCacheBustURLsMatching: z.instanceof(RegExp).optional(),
|
|
32
|
+
manifestTransforms: z.array(manifestTransform).optional(),
|
|
33
|
+
maximumFileSizeToCacheInBytes: z.number().default(2097152),
|
|
34
|
+
modifyURLPrefix: z.record(z.string(), z.string()).optional()
|
|
35
|
+
}).strict("Do not pass invalid properties to BasePartial!");
|
|
36
|
+
|
|
37
|
+
const globPartial = z.object({
|
|
38
|
+
globFollow: z.boolean().default(true),
|
|
39
|
+
globIgnores: z.array(z.string()).default([
|
|
40
|
+
"**/node_modules/**/*"
|
|
41
|
+
]),
|
|
42
|
+
globPatterns: z.array(z.string()).default([
|
|
43
|
+
"**/*.{js,css,html}"
|
|
44
|
+
]),
|
|
45
|
+
globStrict: z.boolean().default(true),
|
|
46
|
+
templatedURLs: z.record(z.string(), z.union([
|
|
47
|
+
z.string(),
|
|
48
|
+
z.array(z.string())
|
|
49
|
+
])).optional()
|
|
50
|
+
}).strict("Do not pass invalid properties to GlobPartial!");
|
|
51
|
+
z.object({
|
|
52
|
+
globDirectory: z.string().optional()
|
|
53
|
+
}).strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!");
|
|
54
|
+
// This needs to be set when using GetManifest or InjectManifest. This is
|
|
55
|
+
// enforced via runtime validation, and needs to be documented.
|
|
56
|
+
const requiredGlobDirectoryPartial = z.object({
|
|
57
|
+
globDirectory: z.string()
|
|
58
|
+
}).strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!");
|
|
59
|
+
|
|
60
|
+
export { basePartial as b, globPartial as g, requiredGlobDirectoryPartial as r };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { b as basePartial, g as globPartial, r as requiredGlobDirectoryPartial } from './glob.js';
|
|
3
|
+
|
|
4
|
+
const optionalSwDestPartial = z.object({
|
|
5
|
+
swDest: z.string().optional()
|
|
6
|
+
}).strict("Do not pass invalid properties to OptionalSwDest!");
|
|
7
|
+
const requiredSwDestPartial = z.object({
|
|
8
|
+
swDest: z.string()
|
|
9
|
+
}).strict("Do not pass invalid properties to RequiredSwDest!");
|
|
10
|
+
|
|
11
|
+
const injectPartial = z.object({
|
|
12
|
+
injectionPoint: z.string().default("self.__SW_MANIFEST"),
|
|
13
|
+
swSrc: z.string()
|
|
14
|
+
}).strict("Do not pass invalid properties to InjectPartial!");
|
|
15
|
+
const injectManifestOptions = basePartial.merge(globPartial).merge(injectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to InjectManifestOptions!");
|
|
16
|
+
|
|
17
|
+
var injectManifest = /*#__PURE__*/Object.freeze({
|
|
18
|
+
__proto__: null,
|
|
19
|
+
injectManifestOptions: injectManifestOptions,
|
|
20
|
+
injectPartial: injectPartial
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { injectManifest as a, injectPartial as i, optionalSwDestPartial as o, requiredSwDestPartial as r };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const validationErrorMap = (error, ctx)=>{
|
|
4
|
+
/*
|
|
5
|
+
This is where you override the various error codes
|
|
6
|
+
*/ switch(error.code){
|
|
7
|
+
case z.ZodIssueCode.invalid_type:
|
|
8
|
+
{
|
|
9
|
+
return {
|
|
10
|
+
message: `${error.message ?? "Received invalid type"}: expected ${error.expected}, received ${error.received}.`
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
case z.ZodIssueCode.invalid_literal:
|
|
14
|
+
{
|
|
15
|
+
return {
|
|
16
|
+
message: `${error.message ?? "Received invalid literal"}: expected ${error.expected}, received ${error.received}.`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
case z.ZodIssueCode.unrecognized_keys:
|
|
20
|
+
{
|
|
21
|
+
return {
|
|
22
|
+
message: `${error.message ?? "Received unrecognized keys"}: ${error.keys.join(",")}`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
case z.ZodIssueCode.invalid_arguments:
|
|
26
|
+
{
|
|
27
|
+
return {
|
|
28
|
+
message: `${error.message ?? "Received invalid arguments"}: ${error.argumentsError.errors.map((e)=>validationErrorMap(e, ctx)).join(",")}.`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
case z.ZodIssueCode.invalid_return_type:
|
|
32
|
+
{
|
|
33
|
+
return {
|
|
34
|
+
message: `${error.message ?? "Received invalid return type"}: ${error.returnTypeError.errors.map((e)=>validationErrorMap(e, ctx)).join(",")}.`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
case z.ZodIssueCode.custom:
|
|
38
|
+
{
|
|
39
|
+
return {
|
|
40
|
+
message: error.message ?? ctx.defaultError
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Fallback to the default message.
|
|
45
|
+
return {
|
|
46
|
+
message: ctx.defaultError
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
class SerwistConfigError extends Error {
|
|
51
|
+
constructor({ moduleName, message }){
|
|
52
|
+
super(`Received an invalid ${moduleName ?? "Serwist"} configuration: ${message}`);
|
|
53
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { SerwistConfigError as S, validationErrorMap as v };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { b as basePartial, g as globPartial, r as requiredGlobDirectoryPartial } from './glob.js';
|
|
2
|
+
import { i as injectPartial, r as requiredSwDestPartial } from './injectManifest.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
const viteInjectManifestOptions = basePartial.merge(globPartial).merge(injectPartial).merge(requiredSwDestPartial).merge(requiredGlobDirectoryPartial).strict("Do not pass invalid properties to ViteInjectManifestPartial!");
|
|
6
|
+
|
|
7
|
+
export { viteInjectManifestOptions };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { b as basePartial } from './glob.js';
|
|
3
|
+
import { i as injectPartial, o as optionalSwDestPartial } from './injectManifest.js';
|
|
4
|
+
|
|
5
|
+
const webpackPartial = z.object({
|
|
6
|
+
chunks: z.array(z.string()).optional(),
|
|
7
|
+
exclude: z.array(z.union([
|
|
8
|
+
z.string(),
|
|
9
|
+
z.instanceof(RegExp),
|
|
10
|
+
z.function(z.tuple([
|
|
11
|
+
z.any()
|
|
12
|
+
]), z.boolean())
|
|
13
|
+
])).default([
|
|
14
|
+
/\.map$/,
|
|
15
|
+
/^manifest.*\.js$/
|
|
16
|
+
]),
|
|
17
|
+
excludeChunks: z.array(z.string()).optional(),
|
|
18
|
+
include: z.array(z.union([
|
|
19
|
+
z.string(),
|
|
20
|
+
z.instanceof(RegExp),
|
|
21
|
+
z.function(z.tuple([
|
|
22
|
+
z.any()
|
|
23
|
+
]), z.boolean())
|
|
24
|
+
])).optional(),
|
|
25
|
+
mode: z.string().nullable().optional()
|
|
26
|
+
}).strict("Do not pass invalid properties to WebpackPartial!");
|
|
27
|
+
const webpackInjectManifestPartial = z.object({
|
|
28
|
+
compileSrc: z.boolean().default(true),
|
|
29
|
+
swDest: z.string().optional(),
|
|
30
|
+
webpackCompilationPlugins: z.array(z.any()).optional()
|
|
31
|
+
}).strict("Do not pass invalid properties to WebpackInjectManifestPartial!");
|
|
32
|
+
const webpackInjectManifestOptions = basePartial.merge(webpackPartial).merge(injectPartial).merge(optionalSwDestPartial).merge(webpackInjectManifestPartial).strict("Do not pass invalid properties to WebpackInjectManifestOptions!");
|
|
33
|
+
|
|
34
|
+
export { webpackInjectManifestOptions, webpackInjectManifestPartial, webpackPartial };
|
package/dist/get-manifest.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ import type { GetManifestOptions, GetManifestResult } from "./types.js";
|
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export declare
|
|
18
|
+
export declare const getManifest: (config: GetManifestOptions) => Promise<GetManifestResult>;
|
|
19
|
+
//# sourceMappingURL=get-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-manifest.d.ts","sourceRoot":"","sources":["../src/get-manifest.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,WAAkB,kBAAkB,KAAG,QAAQ,iBAAiB,CAIvF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ import { transformManifest } from "./lib/transform-manifest.js";
|
|
|
11
11
|
import { translateURLToSourcemapPaths } from "./lib/translate-url-to-sourcemap-paths.js";
|
|
12
12
|
import { validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions } from "./lib/validate-options.js";
|
|
13
13
|
export { errors, escapeRegExp, getFileManifestEntries, getManifest, getSourceMapURL, injectManifest, rebasePath, replaceAndUpdateSourceMap, stringify, transformManifest, translateURLToSourcemapPaths, validateInjectManifestOptions, validateViteInjectManifestOptions, validateWebpackInjectManifestOptions, };
|
|
14
|
-
export * from "./types.js";
|
|
14
|
+
export type * from "./types.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,SAAS,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AAEnJ,OAAO,EACL,MAAM,EACN,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,yBAAyB,EACzB,SAAS,EACT,iBAAiB,EACjB,4BAA4B,EAC5B,6BAA6B,EAC7B,iCAAiC,EACjC,oCAAoC,GACrC,CAAC;AAEF,mBAAmB,YAAY,CAAC"}
|