@serwist/build
Advanced tools
Comparing version 9.0.0-preview.16 to 9.0.0-preview.17
@@ -5,3 +5,3 @@ import { z } from 'zod'; | ||
integrity: z.string().optional(), | ||
revision: z.string().nullable(), | ||
revision: z.string().nullable().optional(), | ||
url: z.string() | ||
@@ -8,0 +8,0 @@ }).strict("Do not pass invalid properties to ManifestEntry!"); |
@@ -6,7 +6,9 @@ import stringify from 'fast-json-stable-stringify'; | ||
import crypto from 'node:crypto'; | ||
import path from 'node:path'; | ||
import { globSync } from 'glob'; | ||
import upath from 'upath'; | ||
import { readFileSync } from 'node:fs'; | ||
import fse from 'fs-extra'; | ||
import prettyBytes from 'pretty-bytes'; | ||
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/validationErrorMap.js'; | ||
import upath from 'upath'; | ||
import { SourceMapGenerator, SourceMapConsumer } from 'source-map'; | ||
@@ -104,3 +106,3 @@ import 'zod'; | ||
totalSize += fileDetails.size; | ||
compositeHash += fileDetails.hash; | ||
compositeHash += fileDetails.hash === null ? "" : fileDetails.hash; | ||
} | ||
@@ -123,5 +125,5 @@ const md5 = crypto.createHash("md5"); | ||
function getFileHash(file) { | ||
const getFileHash = (file)=>{ | ||
try { | ||
const buffer = fse.readFileSync(file); | ||
const buffer = readFileSync(file); | ||
return getStringHash(buffer); | ||
@@ -131,3 +133,3 @@ } catch (err) { | ||
} | ||
} | ||
}; | ||
@@ -167,3 +169,3 @@ function getFileSize(file) { | ||
for (const file of globbedFiles){ | ||
const fullPath = upath.join(globDirectory, file); | ||
const fullPath = path.join(globDirectory, file); | ||
const fileSize = getFileSize(fullPath); | ||
@@ -173,3 +175,3 @@ if (fileSize !== null) { | ||
globbedFileDetails.push({ | ||
file: `${upath.relative(globDirectory, fullPath)}`, | ||
file: path.relative(globDirectory, fullPath), | ||
hash: fileHash, | ||
@@ -186,9 +188,7 @@ size: fileSize | ||
function getStringDetails(url, str) { | ||
return { | ||
const getStringDetails = (url, str)=>({ | ||
file: url, | ||
hash: getStringHash(str), | ||
size: str.length | ||
}; | ||
} | ||
}); | ||
@@ -208,3 +208,3 @@ const additionalPrecacheEntriesTransform = (additionalPrecacheEntries)=>{ | ||
} else { | ||
if (additionalEntry && additionalEntry.revision === undefined) { | ||
if (additionalEntry && !additionalEntry.integrity && additionalEntry.revision === undefined) { | ||
stringEntries.add(additionalEntry.url); | ||
@@ -317,9 +317,7 @@ } | ||
const allWarnings = []; | ||
const normalizedManifest = fileDetails.map((fileDetails)=>{ | ||
return { | ||
const normalizedManifest = fileDetails.map((fileDetails)=>({ | ||
url: fileDetails.file.replace(/\\/g, "/"), | ||
revision: fileDetails.hash, | ||
size: fileDetails.size | ||
}; | ||
}); | ||
})); | ||
const transformsToApply = []; | ||
@@ -364,3 +362,3 @@ if (maximumFileSizeToCacheInBytes) { | ||
async function getFileManifestEntries({ additionalPrecacheEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns = [], globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, disablePrecacheManifest }) { | ||
const getFileManifestEntries = async ({ additionalPrecacheEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns = [], globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, disablePrecacheManifest })=>{ | ||
if (disablePrecacheManifest) { | ||
@@ -443,3 +441,3 @@ return { | ||
return transformedManifest; | ||
} | ||
}; | ||
@@ -446,0 +444,0 @@ const validateGetManifestOptions = async (input)=>{ |
@@ -1,7 +0,2 @@ | ||
import type { GlobPartial } from "../types.js"; | ||
interface FileDetails { | ||
file: string; | ||
hash: string; | ||
size: number; | ||
} | ||
import type { FileDetails, GlobPartial } from "../types.js"; | ||
export declare const getFileDetails: ({ globDirectory, globFollow, globIgnores, globPattern, }: Omit<GlobPartial, "globPatterns" | "templatedURLs" | "globDirectory"> & { | ||
@@ -14,3 +9,2 @@ globDirectory: string; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=get-file-details.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare function getFileHash(file: string): string; | ||
export declare const getFileHash: (file: string) => string; | ||
//# sourceMappingURL=get-file-hash.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import type { GetManifestOptions, GetManifestResult } from "../types.js"; | ||
export declare function getFileManifestEntries({ additionalPrecacheEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns, globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, disablePrecacheManifest, }: GetManifestOptions): Promise<GetManifestResult>; | ||
import type { GetManifestOptionsComplete, GetManifestResult } from "../types.js"; | ||
export declare const getFileManifestEntries: ({ additionalPrecacheEntries, dontCacheBustURLsMatching, globDirectory, globFollow, globIgnores, globPatterns, globStrict, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, templatedURLs, disablePrecacheManifest, }: GetManifestOptionsComplete) => Promise<GetManifestResult>; | ||
//# sourceMappingURL=get-file-manifest-entries.d.ts.map |
import type { FileDetails } from "../types.js"; | ||
export declare function getStringDetails(url: string, str: string): FileDetails; | ||
export declare const getStringDetails: (url: string, str: string) => FileDetails; | ||
//# sourceMappingURL=get-string-details.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { BasePartial, FileDetails, ManifestEntry } from "../types.js"; | ||
import type { BaseResolved, FileDetails, ManifestEntry } from "../types.js"; | ||
/** | ||
@@ -56,7 +56,8 @@ * A `ManifestTransform` function can be used to modify the modify the `url` or | ||
} | ||
export declare function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsMatching, fileDetails, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, transformParam, disablePrecacheManifest, }: BasePartial & { | ||
interface TransformManifestOptions extends Pick<BaseResolved, "additionalPrecacheEntries" | "dontCacheBustURLsMatching" | "manifestTransforms" | "maximumFileSizeToCacheInBytes" | "modifyURLPrefix" | "disablePrecacheManifest"> { | ||
fileDetails: FileDetails[]; | ||
transformParam?: unknown; | ||
}): Promise<ManifestTransformResultWithWarnings>; | ||
} | ||
export declare function transformManifest({ additionalPrecacheEntries, dontCacheBustURLsMatching, fileDetails, manifestTransforms, maximumFileSizeToCacheInBytes, modifyURLPrefix, transformParam, disablePrecacheManifest, }: TransformManifestOptions): Promise<ManifestTransformResultWithWarnings>; | ||
export {}; | ||
//# sourceMappingURL=transform-manifest.d.ts.map |
@@ -5,12 +5,12 @@ import { z } from "zod"; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
}, "strict", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>]>, "many">>; | ||
@@ -21,31 +21,31 @@ disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{ | ||
manifest: z.ZodArray<z.ZodObject<{ | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -55,6 +55,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -64,6 +64,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -74,15 +74,15 @@ warnings?: string[] | undefined; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -92,6 +92,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -101,6 +101,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -115,18 +115,18 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
dontCacheBustURLsMatching?: RegExp | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -136,6 +136,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -147,5 +147,5 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
@@ -155,12 +155,12 @@ disablePrecacheManifest?: boolean | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -170,6 +170,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -176,0 +176,0 @@ warnings?: string[] | undefined; |
@@ -7,12 +7,12 @@ import type { z } from "zod"; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
}, "strict", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>]>, "many">>; | ||
@@ -22,31 +22,31 @@ dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{ | ||
manifest: z.ZodArray<z.ZodObject<{ | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -56,6 +56,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -65,6 +65,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -75,15 +75,15 @@ warnings?: string[] | undefined; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -93,6 +93,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -102,6 +102,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -126,18 +126,18 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
dontCacheBustURLsMatching?: RegExp | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -147,6 +147,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -162,18 +162,18 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
dontCacheBustURLsMatching?: RegExp | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -183,6 +183,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -189,0 +189,0 @@ warnings?: string[] | undefined; |
@@ -17,12 +17,12 @@ import { z } from "zod"; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
}, "strict", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>]>, "many">>; | ||
@@ -32,31 +32,31 @@ dontCacheBustURLsMatching: z.ZodOptional<z.ZodType<RegExp, z.ZodTypeDef, RegExp>>; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{ | ||
manifest: z.ZodArray<z.ZodObject<{ | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -66,6 +66,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -75,6 +75,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -85,15 +85,15 @@ warnings?: string[] | undefined; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -103,6 +103,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -112,6 +112,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -142,18 +142,18 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
dontCacheBustURLsMatching?: RegExp | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -163,6 +163,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -180,18 +180,18 @@ warnings?: string[] | undefined; | ||
additionalPrecacheEntries?: (string | { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
})[] | undefined; | ||
dontCacheBustURLsMatching?: RegExp | undefined; | ||
manifestTransforms?: ((args_0: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[], args_1: unknown) => { | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -201,6 +201,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -207,0 +207,0 @@ warnings?: string[] | undefined; |
import { z } from "zod"; | ||
export declare const manifestEntry: z.ZodObject<{ | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
}, "strict", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>; | ||
//# sourceMappingURL=manifestEntry.d.ts.map |
@@ -5,15 +5,15 @@ import { z } from "zod"; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -23,6 +23,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -32,6 +32,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -42,31 +42,31 @@ warnings?: string[] | undefined; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{ | ||
manifest: z.ZodArray<z.ZodObject<{ | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -76,6 +76,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -85,6 +85,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -95,15 +95,15 @@ warnings?: string[] | undefined; | ||
integrity: z.ZodOptional<z.ZodString>; | ||
revision: z.ZodNullable<z.ZodString>; | ||
revision: z.ZodOptional<z.ZodNullable<z.ZodString>>; | ||
url: z.ZodString; | ||
size: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}, { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}>, "many">; | ||
@@ -113,6 +113,6 @@ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -122,6 +122,6 @@ warnings?: string[] | undefined; | ||
manifest: { | ||
revision: string | null; | ||
url: string; | ||
size: number; | ||
integrity?: string | undefined; | ||
revision?: string | null | undefined; | ||
}[]; | ||
@@ -128,0 +128,0 @@ warnings?: string[] | undefined; |
@@ -182,3 +182,3 @@ import type { Require } from "@serwist/utils"; | ||
file: string; | ||
hash: string; | ||
hash: string | null; | ||
size: number; | ||
@@ -185,0 +185,0 @@ } |
{ | ||
"name": "@serwist/build", | ||
"version": "9.0.0-preview.16", | ||
"version": "9.0.0-preview.17", | ||
"type": "module", | ||
@@ -57,3 +57,3 @@ "description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.", | ||
"zod": "3.22.4", | ||
"@serwist/core": "9.0.0-preview.16" | ||
"@serwist/core": "9.0.0-preview.17" | ||
}, | ||
@@ -67,4 +67,4 @@ "devDependencies": { | ||
"typescript": "5.5.0-dev.20240323", | ||
"@serwist/constants": "9.0.0-preview.16", | ||
"@serwist/utils": "9.0.0-preview.16" | ||
"@serwist/constants": "9.0.0-preview.17", | ||
"@serwist/utils": "9.0.0-preview.17" | ||
}, | ||
@@ -71,0 +71,0 @@ "peerDependencies": { |
@@ -33,3 +33,3 @@ /* | ||
} else { | ||
if (additionalEntry && additionalEntry.revision === undefined) { | ||
if (additionalEntry && !additionalEntry.integrity && additionalEntry.revision === undefined) { | ||
stringEntries.add(additionalEntry.url); | ||
@@ -36,0 +36,0 @@ } |
@@ -19,3 +19,3 @@ /* | ||
totalSize += fileDetails.size; | ||
compositeHash += fileDetails.hash; | ||
compositeHash += fileDetails.hash === null ? "" : fileDetails.hash; | ||
} | ||
@@ -22,0 +22,0 @@ |
@@ -8,7 +8,5 @@ /* | ||
*/ | ||
import path from "node:path"; | ||
import { globSync } from "glob"; | ||
import upath from "upath"; | ||
import type { GlobPartial } from "../types.js"; | ||
import type { FileDetails, GlobPartial } from "../types.js"; | ||
import { errors } from "./errors.js"; | ||
@@ -18,8 +16,2 @@ import { getFileHash } from "./get-file-hash.js"; | ||
interface FileDetails { | ||
file: string; | ||
hash: string; | ||
size: number; | ||
} | ||
export const getFileDetails = ({ | ||
@@ -57,3 +49,3 @@ globDirectory, | ||
for (const file of globbedFiles) { | ||
const fullPath = upath.join(globDirectory, file); | ||
const fullPath = path.join(globDirectory, file); | ||
const fileSize = getFileSize(fullPath); | ||
@@ -63,3 +55,3 @@ if (fileSize !== null) { | ||
globbedFileDetails.push({ | ||
file: `${upath.relative(globDirectory, fullPath)}`, | ||
file: path.relative(globDirectory, fullPath), | ||
hash: fileHash, | ||
@@ -66,0 +58,0 @@ size: fileSize, |
@@ -9,3 +9,3 @@ /* | ||
import fse from "fs-extra"; | ||
import { readFileSync } from "node:fs"; | ||
@@ -15,5 +15,5 @@ import { errors } from "./errors.js"; | ||
export function getFileHash(file: string): string { | ||
export const getFileHash = (file: string): string => { | ||
try { | ||
const buffer = fse.readFileSync(file); | ||
const buffer = readFileSync(file); | ||
return getStringHash(buffer); | ||
@@ -23,2 +23,2 @@ } catch (err) { | ||
} | ||
} | ||
}; |
@@ -11,3 +11,3 @@ /* | ||
import type { FileDetails, GetManifestOptions, GetManifestResult } from "../types.js"; | ||
import type { FileDetails, GetManifestOptionsComplete, GetManifestResult } from "../types.js"; | ||
import { errors } from "./errors.js"; | ||
@@ -19,3 +19,3 @@ import { getCompositeDetails } from "./get-composite-details.js"; | ||
export async function getFileManifestEntries({ | ||
export const getFileManifestEntries = async ({ | ||
additionalPrecacheEntries, | ||
@@ -33,3 +33,3 @@ dontCacheBustURLsMatching, | ||
disablePrecacheManifest, | ||
}: GetManifestOptions): Promise<GetManifestResult> { | ||
}: GetManifestOptionsComplete): Promise<GetManifestResult> => { | ||
if (disablePrecacheManifest) { | ||
@@ -129,2 +129,2 @@ return { | ||
return transformedManifest; | ||
} | ||
}; |
@@ -12,8 +12,6 @@ /* | ||
export function getStringDetails(url: string, str: string): FileDetails { | ||
return { | ||
file: url, | ||
hash: getStringHash(str), | ||
size: str.length, | ||
}; | ||
} | ||
export const getStringDetails = (url: string, str: string): FileDetails => ({ | ||
file: url, | ||
hash: getStringHash(str), | ||
size: str.length, | ||
}); |
@@ -9,3 +9,3 @@ /* | ||
import type { BasePartial, FileDetails, ManifestEntry, ManifestTransform } from "../types.js"; | ||
import type { BaseResolved, FileDetails, ManifestEntry, ManifestTransform } from "../types.js"; | ||
import { additionalPrecacheEntriesTransform } from "./additional-precache-entries-transform.js"; | ||
@@ -72,2 +72,21 @@ import { errors } from "./errors.js"; | ||
} | ||
interface ManifestEntryWithSize extends ManifestEntry { | ||
size: number; | ||
} | ||
interface TransformManifestOptions | ||
extends Pick< | ||
BaseResolved, | ||
| "additionalPrecacheEntries" | ||
| "dontCacheBustURLsMatching" | ||
| "manifestTransforms" | ||
| "maximumFileSizeToCacheInBytes" | ||
| "modifyURLPrefix" | ||
| "disablePrecacheManifest" | ||
> { | ||
fileDetails: FileDetails[]; | ||
// When this is called by the webpack plugin, transformParam will be the | ||
// current webpack compilation. | ||
transformParam?: unknown; | ||
} | ||
export async function transformManifest({ | ||
@@ -82,8 +101,3 @@ additionalPrecacheEntries, | ||
disablePrecacheManifest, | ||
}: BasePartial & { | ||
fileDetails: FileDetails[]; | ||
// When this is called by the webpack plugin, transformParam will be the | ||
// current webpack compilation. | ||
transformParam?: unknown; | ||
}): Promise<ManifestTransformResultWithWarnings> { | ||
}: TransformManifestOptions): Promise<ManifestTransformResultWithWarnings> { | ||
if (disablePrecacheManifest) { | ||
@@ -102,9 +116,7 @@ return { | ||
// {url, revision, size} objects, with \ replaced with /. | ||
const normalizedManifest = fileDetails.map((fileDetails) => { | ||
return { | ||
url: fileDetails.file.replace(/\\/g, "/"), | ||
revision: fileDetails.hash, | ||
size: fileDetails.size, | ||
}; | ||
}); | ||
const normalizedManifest: ManifestEntryWithSize[] = fileDetails.map((fileDetails) => ({ | ||
url: fileDetails.file.replace(/\\/g, "/"), | ||
revision: fileDetails.hash, | ||
size: fileDetails.size, | ||
})); | ||
@@ -135,3 +147,3 @@ const transformsToApply: ManifestTransform[] = []; | ||
let transformedManifest: (ManifestEntry & { size: number })[] = normalizedManifest; | ||
let transformedManifest: ManifestEntryWithSize[] = normalizedManifest; | ||
for (const transform of transformsToApply) { | ||
@@ -138,0 +150,0 @@ const result = await transform(transformedManifest, transformParam); |
@@ -6,5 +6,5 @@ import { z } from "zod"; | ||
integrity: z.string().optional(), | ||
revision: z.string().nullable(), | ||
revision: z.string().nullable().optional(), | ||
url: z.string(), | ||
}) | ||
.strict("Do not pass invalid properties to ManifestEntry!"); |
@@ -208,3 +208,3 @@ import type { Require } from "@serwist/utils"; | ||
file: string; | ||
hash: string; | ||
hash: string | null; | ||
size: number; | ||
@@ -211,0 +211,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
153015
3380
+ Added@serwist/core@9.0.0-preview.17(transitive)
- Removed@serwist/core@9.0.0-preview.16(transitive)