@serwist/build
Advanced tools
Comparing version 9.0.0-preview.0 to 9.0.0-preview.1
@@ -54,4 +54,2 @@ import { z } from 'zod'; | ||
}).strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!"); | ||
// This needs to be set when using GetManifest or InjectManifest. This is | ||
// enforced via runtime validation, and needs to be documented. | ||
const requiredGlobDirectoryPartial = z.object({ | ||
@@ -58,0 +56,0 @@ globDirectory: z.string() |
import { z } from 'zod'; | ||
const validationErrorMap = (error, ctx)=>{ | ||
/* | ||
This is where you override the various error codes | ||
*/ switch(error.code){ | ||
switch(error.code){ | ||
case z.ZodIssueCode.invalid_type: | ||
@@ -44,3 +42,2 @@ { | ||
} | ||
// Fallback to the default message. | ||
return { | ||
@@ -47,0 +44,0 @@ message: ctx.defaultError |
@@ -9,2 +9,3 @@ import stringify from 'fast-json-stable-stringify'; | ||
import fse from 'fs-extra'; | ||
import prettyBytes from 'pretty-bytes'; | ||
import { v as validationErrorMap, S as SerwistConfigError } from './chunks/serwist-config-error.js'; | ||
@@ -199,4 +200,2 @@ import { SourceMapGenerator, SourceMapConsumer } from 'source-map'; | ||
for (const additionalEntry of additionalPrecacheEntries){ | ||
// Warn about either a string or an object that lacks a revision property. | ||
// (An object with a revision property set to null is okay.) | ||
if (typeof additionalEntry === "string") { | ||
@@ -232,106 +231,2 @@ stringEntries.add(additionalEntry); | ||
const BYTE_UNITS = [ | ||
'B', | ||
'kB', | ||
'MB', | ||
'GB', | ||
'TB', | ||
'PB', | ||
'EB', | ||
'ZB', | ||
'YB' | ||
]; | ||
const BIBYTE_UNITS = [ | ||
'B', | ||
'KiB', | ||
'MiB', | ||
'GiB', | ||
'TiB', | ||
'PiB', | ||
'EiB', | ||
'ZiB', | ||
'YiB' | ||
]; | ||
const BIT_UNITS = [ | ||
'b', | ||
'kbit', | ||
'Mbit', | ||
'Gbit', | ||
'Tbit', | ||
'Pbit', | ||
'Ebit', | ||
'Zbit', | ||
'Ybit' | ||
]; | ||
const BIBIT_UNITS = [ | ||
'b', | ||
'kibit', | ||
'Mibit', | ||
'Gibit', | ||
'Tibit', | ||
'Pibit', | ||
'Eibit', | ||
'Zibit', | ||
'Yibit' | ||
]; | ||
/* | ||
Formats the given number using `Number#toLocaleString`. | ||
- If locale is a string, the value is expected to be a locale-key (for example: `de`). | ||
- If locale is true, the system default locale is used for translation. | ||
- If no value for locale is specified, the number is returned unmodified. | ||
*/ const toLocaleString = (number, locale, options)=>{ | ||
let result = number; | ||
if (typeof locale === 'string' || Array.isArray(locale)) { | ||
result = number.toLocaleString(locale, options); | ||
} else if (locale === true || options !== undefined) { | ||
result = number.toLocaleString(undefined, options); | ||
} | ||
return result; | ||
}; | ||
function prettyBytes(number, options) { | ||
if (!Number.isFinite(number)) { | ||
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`); | ||
} | ||
options = { | ||
bits: false, | ||
binary: false, | ||
space: true, | ||
...options | ||
}; | ||
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS; | ||
const separator = options.space ? ' ' : ''; | ||
if (options.signed && number === 0) { | ||
return ` 0${separator}${UNITS[0]}`; | ||
} | ||
const isNegative = number < 0; | ||
const prefix = isNegative ? '-' : options.signed ? '+' : ''; | ||
if (isNegative) { | ||
number = -number; | ||
} | ||
let localeOptions; | ||
if (options.minimumFractionDigits !== undefined) { | ||
localeOptions = { | ||
minimumFractionDigits: options.minimumFractionDigits | ||
}; | ||
} | ||
if (options.maximumFractionDigits !== undefined) { | ||
localeOptions = { | ||
maximumFractionDigits: options.maximumFractionDigits, | ||
...localeOptions | ||
}; | ||
} | ||
if (number < 1) { | ||
const numberString = toLocaleString(number, options.locale, localeOptions); | ||
return prefix + numberString + separator + UNITS[0]; | ||
} | ||
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1); | ||
number /= (options.binary ? 1024 : 1000) ** exponent; | ||
if (!localeOptions) { | ||
number = number.toPrecision(3); | ||
} | ||
const numberString = toLocaleString(Number(number), options.locale, localeOptions); | ||
const unit = UNITS[exponent]; | ||
return prefix + numberString + separator + unit; | ||
} | ||
function maximumSizeTransform(maximumFileSizeToCacheInBytes) { | ||
@@ -354,9 +249,2 @@ return (originalManifest)=>{ | ||
/* | ||
Copyright 2019 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions | ||
const escapeRegExp = (str)=>{ | ||
@@ -370,4 +258,2 @@ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
} | ||
// If there are no entries in modifyURLPrefix, just return an identity | ||
// function as a shortcut. | ||
if (Object.keys(modifyURLPrefix).length === 0) { | ||
@@ -385,8 +271,4 @@ return (manifest)=>{ | ||
} | ||
// Escape the user input so it's safe to use in a regex. | ||
const safeModifyURLPrefixes = Object.keys(modifyURLPrefix).map(escapeRegExp); | ||
// Join all the `modifyURLPrefix` keys so a single regex can be used. | ||
const prefixMatchesStrings = safeModifyURLPrefixes.join("|"); | ||
// Add `^` to the front the prefix matches so it only matches the start of | ||
// a string. | ||
const modifyRegex = new RegExp(`^(${prefixMatchesStrings})`); | ||
@@ -439,4 +321,2 @@ return (originalManifest)=>{ | ||
const allWarnings = []; | ||
// Take the array of fileDetail objects and convert it into an array of | ||
// {url, revision, size} objects, with \ replaced with /. | ||
const normalizedManifest = fileDetails.map((fileDetails)=>{ | ||
@@ -459,7 +339,5 @@ return { | ||
} | ||
// Run any manifestTransforms functions second-to-last. | ||
if (manifestTransforms) { | ||
transformsToApply.push(...manifestTransforms); | ||
} | ||
// Run additionalPrecacheEntriesTransform last. | ||
if (additionalPrecacheEntries) { | ||
@@ -477,4 +355,2 @@ transformsToApply.push(additionalPrecacheEntriesTransform(additionalPrecacheEntries)); | ||
} | ||
// Generate some metadata about the manifest before we clear out the size | ||
// properties from each entry. | ||
const count = transformedManifest.length; | ||
@@ -484,3 +360,2 @@ let size = 0; | ||
size += manifestEntry.size || 0; | ||
// biome-ignore lint/performance/noDelete: I don't understand this part yet. | ||
delete manifestEntry.size; | ||
@@ -526,4 +401,2 @@ } | ||
} catch (error) { | ||
// If there's an exception thrown while globbing, then report | ||
// it back as a warning, and don't consider it fatal. | ||
if (error instanceof Error && error.message) { | ||
@@ -628,18 +501,3 @@ warnings.push(error.message); | ||
/** | ||
* This method returns a list of URLs to precache, referred to as a "precache | ||
* manifest", along with details about the number of entries and their size, | ||
* based on the options you provide. | ||
* | ||
* ``` | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* const {count, manifestEntries, size, warnings} = await getManifest({ | ||
* dontCacheBustURLsMatching: [new RegExp('...')], | ||
* globDirectory: '...', | ||
* globPatterns: ['...', '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* }); | ||
* ``` | ||
*/ const getManifest = async (config)=>{ | ||
const getManifest = async (config)=>{ | ||
const options = await validateGetManifestOptions(config); | ||
@@ -649,10 +507,2 @@ return await getFileManifestEntries(options); | ||
/* | ||
Copyright 2022 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ // Adapted from https://github.com/lydell/source-map-url/blob/master/source-map-url.js | ||
// See https://github.com/GoogleChrome/workbox/issues/3019 | ||
const innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/; | ||
@@ -666,7 +516,4 @@ const regex = RegExp(`(?:/\\*(?:\\s*\r?\n(?://)?)?(?:${innerRegex.source})\\s*\\*/|//(?:${innerRegex.source}))\\s*`); | ||
function rebasePath({ baseDirectory, file }) { | ||
// The initial path is relative to the current directory, so make it absolute. | ||
const absolutePath = upath.resolve(file); | ||
// Convert the absolute path so that it's relative to the baseDirectory. | ||
const relativePath = upath.relative(baseDirectory, absolutePath); | ||
// Remove any leading ./ as it won't work in a glob pattern. | ||
const normalizedPath = upath.normalize(relativePath); | ||
@@ -676,11 +523,3 @@ return normalizedPath; | ||
/** | ||
* Adapted from https://github.com/nsams/sourcemap-aware-replace, with modern | ||
* JavaScript updates, along with additional properties copied from originalMap. | ||
* | ||
* @param options | ||
* @returns An object containing both | ||
* originalSource with the replacement applied, and the modified originalMap. | ||
* @private | ||
*/ async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString }) { | ||
async function replaceAndUpdateSourceMap({ jsFilename, originalMap, originalSource, replaceString, searchString }) { | ||
const generator = new SourceMapGenerator({ | ||
@@ -735,4 +574,2 @@ file: jsFilename | ||
consumer.destroy(); | ||
// JSON.parse returns any. | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const updatedSourceMap = Object.assign(JSON.parse(generator.toString()), { | ||
@@ -770,30 +607,4 @@ names: originalMap.names, | ||
/** | ||
* This method creates a list of URLs to precache, referred to as a "precache | ||
* manifest", based on the options you provide. | ||
* | ||
* The manifest is injected into the `swSrc` file, and the placeholder string | ||
* `injectionPoint` determines where in the file the manifest should go. | ||
* | ||
* The final service worker file, with the manifest injected, is written to | ||
* disk at `swDest`. | ||
* | ||
* This method will not compile or bundle your `swSrc` file; it just handles | ||
* injecting the manifest. | ||
* | ||
* ``` | ||
* // The following lists some common options; see the rest of the documentation | ||
* // for the full set of options and defaults. | ||
* const {count, size, warnings} = await injectManifest({ | ||
* dontCacheBustURLsMatching: [new RegExp('...')], | ||
* globDirectory: '...', | ||
* globPatterns: ['...', '...'], | ||
* maximumFileSizeToCacheInBytes: ..., | ||
* swDest: '...', | ||
* swSrc: '...', | ||
* }); | ||
* ``` | ||
*/ const injectManifest = async (config)=>{ | ||
const injectManifest = async (config)=>{ | ||
const options = await validateInjectManifestOptions(config); | ||
// Make sure we leave swSrc and swDest out of the precache manifest. | ||
for (const file of [ | ||
@@ -817,3 +628,2 @@ options.swSrc, | ||
const injectionResults = swFileContents.match(globalRegexp); | ||
// See https://github.com/GoogleChrome/workbox/issues/2230 | ||
const injectionPoint = options.injectionPoint ? options.injectionPoint : ""; | ||
@@ -830,3 +640,2 @@ if (!injectionResults) { | ||
const url = getSourceMapURL(swFileContents); | ||
// See https://github.com/GoogleChrome/workbox/issues/2957 | ||
const { destPath, srcPath, warning } = translateURLToSourcemapPaths(url, options.swSrc, options.swDest); | ||
@@ -836,8 +645,2 @@ if (warning) { | ||
} | ||
// If our swSrc file contains a sourcemap, we would invalidate that | ||
// mapping if we just replaced injectionPoint with the stringified manifest. | ||
// Instead, we need to update the swDest contents as well as the sourcemap | ||
// (assuming it's a real file, not a data: URL) at the same time. | ||
// See https://github.com/GoogleChrome/workbox/issues/2235 | ||
// and https://github.com/GoogleChrome/workbox/issues/2648 | ||
if (srcPath && destPath) { | ||
@@ -857,4 +660,2 @@ const originalMap = await fse.readJSON(srcPath, { | ||
} else { | ||
// If there's no sourcemap associated with swSrc, a simple string | ||
// replacement will suffice. | ||
filesToWrite[options.swDest] = swFileContents.replace(globalRegexp, manifestString); | ||
@@ -874,3 +675,2 @@ } | ||
warnings, | ||
// Use upath.resolve() to make all the paths absolute. | ||
filePaths: Object.keys(filesToWrite).map((f)=>upath.resolve(f)) | ||
@@ -877,0 +677,0 @@ }; |
@@ -8,3 +8,3 @@ import { z } from 'zod'; | ||
const nextInjectManifestPartial = z.object({ | ||
cacheOnFrontEndNav: z.boolean().default(false), | ||
cacheOnNavigation: z.boolean().default(false), | ||
disable: z.boolean().default(false), | ||
@@ -15,3 +15,6 @@ register: z.boolean().default(true), | ||
swUrl: z.string().default("/sw.js"), | ||
globPublicPatterns: z.array(z.string()).default([ | ||
globPublicPatterns: z.union([ | ||
z.string(), | ||
z.array(z.string()) | ||
]).default([ | ||
"**/*" | ||
@@ -18,0 +21,0 @@ ]) |
import { z } from "zod"; | ||
export declare const nextInjectManifestPartial: z.ZodObject<{ | ||
cacheOnFrontEndNav: z.ZodDefault<z.ZodBoolean>; | ||
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>; | ||
disable: z.ZodDefault<z.ZodBoolean>; | ||
@@ -9,5 +9,5 @@ register: z.ZodDefault<z.ZodBoolean>; | ||
swUrl: z.ZodDefault<z.ZodString>; | ||
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; | ||
globPublicPatterns: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>; | ||
}, "strict", z.ZodTypeAny, { | ||
cacheOnFrontEndNav: boolean; | ||
cacheOnNavigation: boolean; | ||
disable: boolean; | ||
@@ -17,6 +17,6 @@ register: boolean; | ||
swUrl: string; | ||
globPublicPatterns: string[]; | ||
globPublicPatterns: (string | string[]) & (string | string[] | undefined); | ||
scope?: string | undefined; | ||
}, { | ||
cacheOnFrontEndNav?: boolean | undefined; | ||
cacheOnNavigation?: boolean | undefined; | ||
disable?: boolean | undefined; | ||
@@ -27,3 +27,3 @@ register?: boolean | undefined; | ||
swUrl?: string | undefined; | ||
globPublicPatterns?: string[] | undefined; | ||
globPublicPatterns?: string | string[] | undefined; | ||
}>; | ||
@@ -142,3 +142,3 @@ export declare const nextInjectManifestOptions: z.ZodObject<Omit<{ | ||
swDest: z.ZodString; | ||
cacheOnFrontEndNav: z.ZodDefault<z.ZodBoolean>; | ||
cacheOnNavigation: z.ZodDefault<z.ZodBoolean>; | ||
disable: z.ZodDefault<z.ZodBoolean>; | ||
@@ -149,3 +149,3 @@ register: z.ZodDefault<z.ZodBoolean>; | ||
swUrl: z.ZodDefault<z.ZodString>; | ||
globPublicPatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; | ||
globPublicPatterns: z.ZodDefault<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>; | ||
}, "disablePrecacheManifest">, "strict", z.ZodTypeAny, { | ||
@@ -157,3 +157,3 @@ maximumFileSizeToCacheInBytes: number; | ||
compileSrc: boolean; | ||
cacheOnFrontEndNav: boolean; | ||
cacheOnNavigation: boolean; | ||
disable: boolean; | ||
@@ -163,3 +163,3 @@ register: boolean; | ||
swUrl: string; | ||
globPublicPatterns: string[]; | ||
globPublicPatterns: (string | string[]) & (string | string[] | undefined); | ||
swDest: string; | ||
@@ -242,3 +242,3 @@ additionalPrecacheEntries?: (string | { | ||
webpackCompilationPlugins?: any[] | undefined; | ||
cacheOnFrontEndNav?: boolean | undefined; | ||
cacheOnNavigation?: boolean | undefined; | ||
disable?: boolean | undefined; | ||
@@ -248,5 +248,5 @@ register?: boolean | undefined; | ||
swUrl?: string | undefined; | ||
globPublicPatterns?: string[] | undefined; | ||
globPublicPatterns?: string | string[] | undefined; | ||
scope?: string | undefined; | ||
}>; | ||
//# sourceMappingURL=next.d.ts.map |
@@ -226,3 +226,3 @@ import type { Require } from "@serwist/utils"; | ||
*/ | ||
cacheOnFrontEndNav?: boolean; | ||
cacheOnNavigation?: boolean; | ||
/** | ||
@@ -308,3 +308,3 @@ * Whether Serwist should be disabled. | ||
} | ||
export type NextInjectManifestResolved = Require<NextInjectManifestPartial, "cacheOnFrontEndNav" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">; | ||
export type NextInjectManifestResolved = Require<NextInjectManifestPartial, "cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns">; | ||
export type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial; | ||
@@ -311,0 +311,0 @@ export type GetManifestOptionsComplete = BaseResolved & GlobResolved & RequiredGlobDirectoryResolved; |
{ | ||
"name": "@serwist/build", | ||
"version": "9.0.0-preview.0", | ||
"version": "9.0.0-preview.1", | ||
"type": "module", | ||
@@ -53,2 +53,3 @@ "description": "A module that integrates into your build process, helping you generate a manifest of local files that should be precached.", | ||
"glob": "10.3.10", | ||
"pretty-bytes": "6.1.1", | ||
"rollup": "4.9.6", | ||
@@ -58,10 +59,10 @@ "source-map": "0.8.0-beta.0", | ||
"zod": "3.22.4", | ||
"@serwist/background-sync": "9.0.0-preview.0", | ||
"@serwist/broadcast-update": "9.0.0-preview.0", | ||
"@serwist/cacheable-response": "9.0.0-preview.0", | ||
"@serwist/core": "9.0.0-preview.0", | ||
"@serwist/expiration": "9.0.0-preview.0", | ||
"@serwist/google-analytics": "9.0.0-preview.0", | ||
"@serwist/precaching": "9.0.0-preview.0", | ||
"@serwist/routing": "9.0.0-preview.0" | ||
"@serwist/background-sync": "9.0.0-preview.1", | ||
"@serwist/broadcast-update": "9.0.0-preview.1", | ||
"@serwist/cacheable-response": "9.0.0-preview.1", | ||
"@serwist/core": "9.0.0-preview.1", | ||
"@serwist/expiration": "9.0.0-preview.1", | ||
"@serwist/google-analytics": "9.0.0-preview.1", | ||
"@serwist/precaching": "9.0.0-preview.1", | ||
"@serwist/routing": "9.0.0-preview.1" | ||
}, | ||
@@ -73,7 +74,6 @@ "devDependencies": { | ||
"@types/stringify-object": "4.0.5", | ||
"pretty-bytes": "6.1.1", | ||
"type-fest": "4.10.2", | ||
"typescript": "5.4.0-dev.20240203", | ||
"@serwist/constants": "9.0.0-preview.0", | ||
"@serwist/utils": "9.0.0-preview.0" | ||
"@serwist/constants": "9.0.0-preview.1", | ||
"@serwist/utils": "9.0.0-preview.1" | ||
}, | ||
@@ -80,0 +80,0 @@ "peerDependencies": { |
import { z } from "zod"; | ||
import type { BasePartial, BaseResolved } from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { manifestEntry } from "./manifestEntry.js"; | ||
@@ -16,2 +17,5 @@ import { manifestTransform } from "./manifestTransform.js"; | ||
}) | ||
.strict("Do not pass invalid properties to BasePartial!") satisfies z.ZodType<BaseResolved, z.ZodObjectDef, BasePartial>; | ||
.strict("Do not pass invalid properties to BasePartial!"); | ||
assertType<Equals<BasePartial, z.input<typeof basePartial>>>(); | ||
assertType<Equals<BaseResolved, z.output<typeof basePartial>>>(); |
import type { z } from "zod"; | ||
import type { GetManifestOptions, GetManifestOptionsComplete } from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { basePartial } from "./base.js"; | ||
@@ -10,6 +10,5 @@ import { globPartial, requiredGlobDirectoryPartial } from "./glob.js"; | ||
.merge(requiredGlobDirectoryPartial) | ||
.strict("Do not pass invalid properties to GetManifestOptions!") satisfies z.ZodType< | ||
GetManifestOptionsComplete, | ||
z.ZodObjectDef, | ||
GetManifestOptions | ||
>; | ||
.strict("Do not pass invalid properties to GetManifestOptions!"); | ||
assertType<Equals<GetManifestOptions, z.input<typeof getManifestOptions>>>(); | ||
assertType<Equals<GetManifestOptionsComplete, z.output<typeof getManifestOptions>>>(); |
@@ -10,2 +10,3 @@ import { z } from "zod"; | ||
} from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
@@ -20,3 +21,3 @@ export const globPartial = z | ||
}) | ||
.strict("Do not pass invalid properties to GlobPartial!") satisfies z.ZodType<GlobResolved, z.ZodObjectDef, GlobPartial>; | ||
.strict("Do not pass invalid properties to GlobPartial!"); | ||
@@ -27,7 +28,3 @@ export const optionalGlobDirectoryPartial = z | ||
}) | ||
.strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!") satisfies z.ZodType< | ||
OptionalGlobDirectoryResolved, | ||
z.ZodObjectDef, | ||
OptionalGlobDirectoryPartial | ||
>; | ||
.strict("Do not pass invalid properties to OptionalGlobDirectoryPartial!"); | ||
@@ -40,6 +37,9 @@ // This needs to be set when using GetManifest or InjectManifest. This is | ||
}) | ||
.strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!") satisfies z.ZodType< | ||
RequiredGlobDirectoryResolved, | ||
z.ZodObjectDef, | ||
RequiredGlobDirectoryPartial | ||
>; | ||
.strict("Do not pass invalid properties to RequiredGlobDirectoryPartial!"); | ||
assertType<Equals<GlobPartial, z.input<typeof globPartial>>>(); | ||
assertType<Equals<GlobResolved, z.output<typeof globPartial>>>(); | ||
assertType<Equals<OptionalGlobDirectoryPartial, z.input<typeof optionalGlobDirectoryPartial>>>(); | ||
assertType<Equals<OptionalGlobDirectoryResolved, z.output<typeof optionalGlobDirectoryPartial>>>(); | ||
assertType<Equals<RequiredGlobDirectoryPartial, z.input<typeof requiredGlobDirectoryPartial>>>(); | ||
assertType<Equals<RequiredGlobDirectoryResolved, z.output<typeof requiredGlobDirectoryPartial>>>(); |
import { z } from "zod"; | ||
import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { basePartial } from "./base.js"; | ||
@@ -12,3 +13,3 @@ import { globPartial, requiredGlobDirectoryPartial } from "./glob.js"; | ||
}) | ||
.strict("Do not pass invalid properties to InjectPartial!") satisfies z.ZodType<InjectResolved, z.ZodObjectDef, InjectPartial>; | ||
.strict("Do not pass invalid properties to InjectPartial!"); | ||
@@ -20,6 +21,7 @@ export const injectManifestOptions = basePartial | ||
.merge(requiredGlobDirectoryPartial) | ||
.strict("Do not pass invalid properties to InjectManifestOptions!") satisfies z.ZodType< | ||
InjectManifestOptionsComplete, | ||
z.ZodObjectDef, | ||
InjectManifestOptions | ||
>; | ||
.strict("Do not pass invalid properties to InjectManifestOptions!"); | ||
assertType<Equals<InjectPartial, z.input<typeof injectPartial>>>(); | ||
assertType<Equals<InjectResolved, z.output<typeof injectPartial>>>(); | ||
assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>(); | ||
assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>(); |
@@ -8,2 +8,3 @@ import { z } from "zod"; | ||
} from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { requiredSwDestPartial } from "./swDest.js"; | ||
@@ -14,3 +15,3 @@ import { webpackInjectManifestOptions } from "./webpack.js"; | ||
.object({ | ||
cacheOnFrontEndNav: z.boolean().default(false), | ||
cacheOnNavigation: z.boolean().default(false), | ||
disable: z.boolean().default(false), | ||
@@ -21,9 +22,5 @@ register: z.boolean().default(true), | ||
swUrl: z.string().default("/sw.js"), | ||
globPublicPatterns: z.array(z.string()).default(["**/*"]), | ||
globPublicPatterns: z.union([z.string(), z.array(z.string())]).default(["**/*"]), | ||
}) | ||
.strict("Do not pass invalid properties to NextInjectManifestPartial!") satisfies z.ZodType< | ||
NextInjectManifestResolved, | ||
z.ZodObjectDef, | ||
NextInjectManifestPartial | ||
>; | ||
.strict("Do not pass invalid properties to NextInjectManifestPartial!"); | ||
@@ -34,6 +31,7 @@ export const nextInjectManifestOptions = webpackInjectManifestOptions | ||
.omit({ disablePrecacheManifest: true }) | ||
.strict("Do not pass invalid properties to NextInjectManifestOptions!") satisfies z.ZodType< | ||
NextInjectManifestOptionsComplete, | ||
z.ZodObjectDef, | ||
NextInjectManifestOptions | ||
>; | ||
.strict("Do not pass invalid properties to NextInjectManifestOptions!"); | ||
assertType<Equals<NextInjectManifestPartial, z.input<typeof nextInjectManifestPartial>>>(); | ||
assertType<Equals<NextInjectManifestResolved, z.output<typeof nextInjectManifestPartial>>>(); | ||
assertType<Equals<NextInjectManifestOptions, z.input<typeof nextInjectManifestOptions>>>(); | ||
assertType<Equals<NextInjectManifestOptionsComplete, z.output<typeof nextInjectManifestOptions>>>(); |
import { z } from "zod"; | ||
import type { OptionalSwDestPartial, OptionalSwDestResolved, RequiredSwDestPartial, RequiredSwDestResolved } from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
@@ -8,3 +9,3 @@ export const optionalSwDestPartial = z | ||
}) | ||
.strict("Do not pass invalid properties to OptionalSwDest!") satisfies z.ZodType<OptionalSwDestResolved, z.ZodObjectDef, OptionalSwDestPartial>; | ||
.strict("Do not pass invalid properties to OptionalSwDest!"); | ||
@@ -15,2 +16,7 @@ export const requiredSwDestPartial = z | ||
}) | ||
.strict("Do not pass invalid properties to RequiredSwDest!") satisfies z.ZodType<RequiredSwDestResolved, z.ZodObjectDef, RequiredSwDestPartial>; | ||
.strict("Do not pass invalid properties to RequiredSwDest!"); | ||
assertType<Equals<OptionalSwDestPartial, z.input<typeof optionalSwDestPartial>>>(); | ||
assertType<Equals<OptionalSwDestResolved, z.output<typeof optionalSwDestPartial>>>(); | ||
assertType<Equals<RequiredSwDestPartial, z.input<typeof requiredSwDestPartial>>>(); | ||
assertType<Equals<RequiredSwDestResolved, z.output<typeof requiredSwDestPartial>>>(); |
import type { z } from "zod"; | ||
import type { ViteInjectManifestOptions, ViteInjectManifestOptionsComplete } from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { basePartial } from "./base.js"; | ||
@@ -14,6 +15,5 @@ import { globPartial } from "./glob.js"; | ||
.merge(requiredGlobDirectoryPartial) | ||
.strict("Do not pass invalid properties to ViteInjectManifestPartial!") satisfies z.ZodType< | ||
ViteInjectManifestOptionsComplete, | ||
z.ZodObjectDef, | ||
ViteInjectManifestOptions | ||
>; | ||
.strict("Do not pass invalid properties to ViteInjectManifestPartial!"); | ||
assertType<Equals<ViteInjectManifestOptions, z.input<typeof viteInjectManifestOptions>>>(); | ||
assertType<Equals<ViteInjectManifestOptionsComplete, z.output<typeof viteInjectManifestOptions>>>(); |
@@ -10,2 +10,3 @@ import { z } from "zod"; | ||
} from "../types.js"; | ||
import { type Equals, assertType } from "./assertType.js"; | ||
import { basePartial } from "./base.js"; | ||
@@ -25,3 +26,3 @@ import { injectPartial } from "./injectManifest.js"; | ||
}) | ||
.strict("Do not pass invalid properties to WebpackPartial!") satisfies z.ZodType<WebpackResolved, z.ZodObjectDef, WebpackPartial>; | ||
.strict("Do not pass invalid properties to WebpackPartial!"); | ||
@@ -34,7 +35,3 @@ export const webpackInjectManifestPartial = z | ||
}) | ||
.strict("Do not pass invalid properties to WebpackInjectManifestPartial!") satisfies z.ZodType< | ||
WebpackInjectManifestResolved, | ||
z.ZodObjectDef, | ||
WebpackInjectManifestPartial | ||
>; | ||
.strict("Do not pass invalid properties to WebpackInjectManifestPartial!"); | ||
@@ -46,6 +43,9 @@ export const webpackInjectManifestOptions = basePartial | ||
.merge(webpackInjectManifestPartial) | ||
.strict("Do not pass invalid properties to WebpackInjectManifestOptions!") satisfies z.ZodType< | ||
WebpackInjectManifestOptionsComplete, | ||
z.ZodObjectDef, | ||
WebpackInjectManifestOptions | ||
>; | ||
.strict("Do not pass invalid properties to WebpackInjectManifestOptions!"); | ||
assertType<Equals<WebpackPartial, z.input<typeof webpackPartial>>>(); | ||
assertType<Equals<WebpackResolved, z.output<typeof webpackPartial>>>(); | ||
assertType<Equals<WebpackInjectManifestPartial, z.input<typeof webpackInjectManifestPartial>>>(); | ||
assertType<Equals<WebpackInjectManifestResolved, z.output<typeof webpackInjectManifestPartial>>>(); | ||
assertType<Equals<WebpackInjectManifestOptions, z.input<typeof webpackInjectManifestOptions>>>(); | ||
assertType<Equals<WebpackInjectManifestOptionsComplete, z.output<typeof webpackInjectManifestOptions>>>(); |
@@ -257,3 +257,3 @@ import type { Require } from "@serwist/utils"; | ||
*/ | ||
cacheOnFrontEndNav?: boolean; | ||
cacheOnNavigation?: boolean; | ||
/** | ||
@@ -342,3 +342,3 @@ * Whether Serwist should be disabled. | ||
NextInjectManifestPartial, | ||
"cacheOnFrontEndNav" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns" | ||
"cacheOnNavigation" | "disable" | "register" | "reloadOnOnline" | "swUrl" | "globPublicPatterns" | ||
>; | ||
@@ -345,0 +345,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
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 1 instance 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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 1 instance in 1 package
8
126
0
204839
19
4676
+ Addedpretty-bytes@6.1.1
+ Added@serwist/background-sync@9.0.0-preview.1(transitive)
+ Added@serwist/broadcast-update@9.0.0-preview.1(transitive)
+ Added@serwist/cacheable-response@9.0.0-preview.1(transitive)
+ Added@serwist/core@9.0.0-preview.1(transitive)
+ Added@serwist/expiration@9.0.0-preview.1(transitive)
+ Added@serwist/google-analytics@9.0.0-preview.1(transitive)
+ Added@serwist/precaching@9.0.0-preview.1(transitive)
+ Added@serwist/routing@9.0.0-preview.1(transitive)
+ Added@serwist/strategies@9.0.0-preview.1(transitive)
+ Addedpretty-bytes@6.1.1(transitive)
- Removed@serwist/background-sync@9.0.0-preview.0(transitive)
- Removed@serwist/broadcast-update@9.0.0-preview.0(transitive)
- Removed@serwist/cacheable-response@9.0.0-preview.0(transitive)
- Removed@serwist/core@9.0.0-preview.0(transitive)
- Removed@serwist/expiration@9.0.0-preview.0(transitive)
- Removed@serwist/google-analytics@9.0.0-preview.0(transitive)
- Removed@serwist/precaching@9.0.0-preview.0(transitive)
- Removed@serwist/routing@9.0.0-preview.0(transitive)
- Removed@serwist/strategies@9.0.0-preview.0(transitive)