@serwist/build
Version:
A module that integrates into your build process, helping you generate a manifest of local files that should be precached.
67 lines (66 loc) • 2.6 kB
JavaScript
import { t as DEFAULT_GLOB_PATTERNS } from "./constants-BLOVm9H2.js";
import { z } from "zod";
//#region src/schema/assert-type.ts
function assertType() {}
//#endregion
//#region src/schema/manifest-entry.ts
const manifestEntry = z.strictObject({
integrity: z.string().optional(),
revision: z.string().nullable().optional(),
url: z.string()
});
//#endregion
//#region src/schema/utils.ts
const fn = ({ input, output }) => {
const schema = z.function({
input: z.tuple(input),
output
});
return z.custom((arg) => typeof arg === "function").transform((arg) => schema.implement(arg));
};
const asyncFn = ({ input, output }) => {
const schema = z.function({
input: z.tuple(input),
output
});
return z.custom((arg) => typeof arg === "function").transform((arg) => schema.implementAsync(arg));
};
//#endregion
//#region src/schema/manifest-transform.ts
const sizeObject = z.object({ size: z.number() });
const manifestEntryWithSize = z.object({
...manifestEntry.shape,
...sizeObject.shape
});
const manifestTransformResult = z.strictObject({
manifest: z.array(manifestEntryWithSize),
warnings: z.array(z.string()).optional()
});
const manifestTransform = asyncFn({
input: [z.array(manifestEntryWithSize), z.unknown().optional()],
output: manifestTransformResult
});
//#endregion
//#region src/schema/base.ts
const basePartial = z.strictObject({
additionalPrecacheEntries: z.array(z.union([z.string(), manifestEntry])).optional(),
disablePrecacheManifest: z.boolean().default(false),
dontCacheBustURLsMatching: z.instanceof(RegExp).optional(),
manifestTransforms: z.array(manifestTransform).optional(),
maximumFileSizeToCacheInBytes: z.number().default(2097152),
modifyURLPrefix: z.record(z.string(), z.string()).optional()
});
//#endregion
//#region src/schema/glob.ts
const globPartial = z.strictObject({
globFollow: z.boolean().default(true),
globIgnores: z.array(z.string()).default(["**/node_modules/**/*"]),
globPatterns: z.array(z.string()).default(DEFAULT_GLOB_PATTERNS),
globStrict: z.boolean().default(true),
templatedURLs: z.record(z.string(), z.union([z.string(), z.array(z.string())])).optional()
});
const optionalGlobDirectoryPartial = z.strictObject({ globDirectory: z.string().optional() });
const requiredGlobDirectoryPartial = z.strictObject({ globDirectory: z.string() });
//#endregion
export { manifestTransform as a, fn as c, basePartial as i, manifestEntry as l, optionalGlobDirectoryPartial as n, manifestTransformResult as o, requiredGlobDirectoryPartial as r, asyncFn as s, globPartial as t, assertType as u };
//# sourceMappingURL=glob-B4_meZ_o.js.map