import { PackageJson } from 'type-fest'; import { BroadcastCacheUpdateOptions } from 'workbox-broadcast-update/BroadcastCacheUpdate'; import { GoogleAnalyticsInitializeOptions } from 'workbox-google-analytics/initialize'; import { HTTPMethod } from 'workbox-routing/utils/constants'; import { QueueOptions } from 'workbox-background-sync/Queue'; import { RouteHandler, RouteMatchCallback } from 'workbox-core/types'; import { CacheableResponseOptions } from 'workbox-cacheable-response/CacheableResponse'; import { ExpirationPluginOptions } from 'workbox-expiration/ExpirationPlugin'; import { WorkboxPlugin } from 'workbox-core/types'; export interface ManifestEntry { integrity?: string; revision: string | null; url: string; } declare type StrategyName = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate'; export interface RuntimeCaching { handler: RouteHandler | StrategyName; method?: HTTPMethod; options?: { backgroundSync?: { name: string; options?: QueueOptions; }; broadcastUpdate?: { channelName?: string; options: BroadcastCacheUpdateOptions; }; cacheableResponse?: CacheableResponseOptions; cacheName?: string | null; expiration?: ExpirationPluginOptions; networkTimeoutSeconds?: number; plugins?: Array; precacheFallback?: { fallbackURL: string; }; rangeRequests?: boolean; fetchOptions?: RequestInit; matchOptions?: CacheQueryOptions; }; urlPattern: RegExp | string | RouteMatchCallback; } export interface ManifestTransformResult { manifest: Array; warnings?: Array; } export declare type ManifestTransform = (manifestEntries: Array, compilation?: unknown) => Promise | ManifestTransformResult; export interface BasePartial { additionalManifestEntries?: Array; dontCacheBustURLsMatching?: RegExp; manifestTransforms?: Array; /** * @default 2097152 */ maximumFileSizeToCacheInBytes?: number; modifyURLPrefix?: { [key: string]: string; }; } export interface GeneratePartial { /** * @default ["chrome >= 56"] */ babelPresetEnvTargets?: Array; cacheId?: string | null; /** * @default false */ cleanupOutdatedCaches?: boolean; /** * @default false */ clientsClaim?: boolean; directoryIndex?: string | null; /** * @default false */ disableDevLogs?: boolean; ignoreURLParametersMatching?: Array; importScripts?: Array; /** * @default false */ inlineWorkboxRuntime?: boolean; /** * @default "production" */ mode?: string | null; /** * @default null */ navigateFallback?: string | null; navigateFallbackAllowlist?: Array; navigateFallbackDenylist?: Array; /** * navigationPreload is only valid when runtimeCaching is configured. However, * this can't be expressed via TypeScript, so it's enforced via runtime logic. * @default false */ navigationPreload?: boolean; /** * @default false */ offlineGoogleAnalytics?: boolean | GoogleAnalyticsInitializeOptions; runtimeCaching?: Array; /** * @default false */ skipWaiting?: boolean; /** * @default true */ sourcemap?: boolean; } export interface RequiredGlobDirectoryPartial { globDirectory: string; } export interface OptionalGlobDirectoryPartial { globDirectory?: string; } export interface GlobPartial { /** * @default true */ globFollow?: boolean; /** * @default ["**\/node_modules\/**\/*"] */ globIgnores?: Array; /** * @default ["**\/*.{js,css,html}"] */ globPatterns?: Array; /** * @default true */ globStrict?: boolean; templatedURLs?: { [key: string]: string | Array; }; } interface InjectPartial { /** * @default "self.__WB_MANIFEST" */ injectionPoint?: string; swSrc: string; } interface WebpackPartial { chunks?: Array; exclude?: Array boolean)>; excludeChunks?: Array; include?: Array boolean)>; mode?: string | null; } export interface RequiredSWDestPartial { swDest: string; } interface WebpackGenerateSWPartial { importScriptsViaChunks?: Array; /** * @default "service-worker.js" */ swDest?: string; } interface WebpackInjectManifestPartial { /** * @default true */ compileSrc?: boolean; swDest?: string; webpackCompilationPlugins?: Array; } export declare type GenerateSWOptions = BasePartial & GlobPartial & GeneratePartial & RequiredSWDestPartial & OptionalGlobDirectoryPartial; export declare type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial; export declare type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSWDestPartial & RequiredGlobDirectoryPartial; export declare type WebpackGenerateSWOptions = BasePartial & WebpackPartial & GeneratePartial & WebpackGenerateSWPartial; export declare type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & WebpackInjectManifestPartial; export interface GetManifestResult { count: number; manifestEntries: Array; size: number; warnings: Array; } export declare type BuildResult = Omit & { filePaths: Array; }; export interface FileDetails { file: string; hash: string; size: number; } export declare type BuildType = 'dev' | 'prod'; export interface WorkboxPackageJSON extends PackageJson { workbox?: { browserNamespace?: string; packageType?: string; prodOnly?: boolean; }; } export {};