UNPKG

6.2 kBTypeScriptView Raw
1import { PackageJson } from 'type-fest';
2import { BroadcastCacheUpdateOptions } from 'workbox-broadcast-update/BroadcastCacheUpdate';
3import { GoogleAnalyticsInitializeOptions } from 'workbox-google-analytics/initialize';
4import { HTTPMethod } from 'workbox-routing/utils/constants';
5import { QueueOptions } from 'workbox-background-sync/Queue';
6import { RouteHandler, RouteMatchCallback } from 'workbox-core/types';
7import { CacheableResponseOptions } from 'workbox-cacheable-response/CacheableResponse';
8import { ExpirationPluginOptions } from 'workbox-expiration/ExpirationPlugin';
9import { WorkboxPlugin } from 'workbox-core/types';
10export interface ManifestEntry {
11 integrity?: string;
12 revision: string | null;
13 url: string;
14}
15declare type StrategyName = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate';
16export interface RuntimeCaching {
17 handler: RouteHandler | StrategyName;
18 method?: HTTPMethod;
19 options?: {
20 backgroundSync?: {
21 name: string;
22 options?: QueueOptions;
23 };
24 broadcastUpdate?: {
25 channelName?: string;
26 options: BroadcastCacheUpdateOptions;
27 };
28 cacheableResponse?: CacheableResponseOptions;
29 cacheName?: string | null;
30 expiration?: ExpirationPluginOptions;
31 networkTimeoutSeconds?: number;
32 plugins?: Array<WorkboxPlugin>;
33 precacheFallback?: {
34 fallbackURL: string;
35 };
36 rangeRequests?: boolean;
37 fetchOptions?: RequestInit;
38 matchOptions?: CacheQueryOptions;
39 };
40 urlPattern: RegExp | string | RouteMatchCallback;
41}
42export interface ManifestTransformResult {
43 manifest: Array<ManifestEntry & {
44 size: number;
45 }>;
46 warnings?: Array<string>;
47}
48export declare type ManifestTransform = (manifestEntries: Array<ManifestEntry & {
49 size: number;
50}>, compilation?: unknown) => Promise<ManifestTransformResult> | ManifestTransformResult;
51export interface BasePartial {
52 additionalManifestEntries?: Array<string | ManifestEntry>;
53 dontCacheBustURLsMatching?: RegExp;
54 manifestTransforms?: Array<ManifestTransform>;
55 /**
56 * @default 2097152
57 */
58 maximumFileSizeToCacheInBytes?: number;
59 modifyURLPrefix?: {
60 [key: string]: string;
61 };
62}
63export interface GeneratePartial {
64 /**
65 * @default ["chrome >= 56"]
66 */
67 babelPresetEnvTargets?: Array<string>;
68 cacheId?: string | null;
69 /**
70 * @default false
71 */
72 cleanupOutdatedCaches?: boolean;
73 /**
74 * @default false
75 */
76 clientsClaim?: boolean;
77 directoryIndex?: string | null;
78 /**
79 * @default false
80 */
81 disableDevLogs?: boolean;
82 ignoreURLParametersMatching?: Array<RegExp>;
83 importScripts?: Array<string>;
84 /**
85 * @default false
86 */
87 inlineWorkboxRuntime?: boolean;
88 /**
89 * @default "production"
90 */
91 mode?: string | null;
92 /**
93 * @default null
94 */
95 navigateFallback?: string | null;
96 navigateFallbackAllowlist?: Array<RegExp>;
97 navigateFallbackDenylist?: Array<RegExp>;
98 /**
99 * navigationPreload is only valid when runtimeCaching is configured. However,
100 * this can't be expressed via TypeScript, so it's enforced via runtime logic.
101 * @default false
102 */
103 navigationPreload?: boolean;
104 /**
105 * @default false
106 */
107 offlineGoogleAnalytics?: boolean | GoogleAnalyticsInitializeOptions;
108 runtimeCaching?: Array<RuntimeCaching>;
109 /**
110 * @default false
111 */
112 skipWaiting?: boolean;
113 /**
114 * @default true
115 */
116 sourcemap?: boolean;
117}
118export interface RequiredGlobDirectoryPartial {
119 globDirectory: string;
120}
121export interface OptionalGlobDirectoryPartial {
122 globDirectory?: string;
123}
124export interface GlobPartial {
125 /**
126 * @default true
127 */
128 globFollow?: boolean;
129 /**
130 * @default ["**\/node_modules\/**\/*"]
131 */
132 globIgnores?: Array<string>;
133 /**
134 * @default ["**\/*.{js,css,html}"]
135 */
136 globPatterns?: Array<string>;
137 /**
138 * @default true
139 */
140 globStrict?: boolean;
141 templatedURLs?: {
142 [key: string]: string | Array<string>;
143 };
144}
145interface InjectPartial {
146 /**
147 * @default "self.__WB_MANIFEST"
148 */
149 injectionPoint?: string;
150 swSrc: string;
151}
152interface WebpackPartial {
153 chunks?: Array<string>;
154 exclude?: Array<string | RegExp | ((arg0: string) => boolean)>;
155 excludeChunks?: Array<string>;
156 include?: Array<string | RegExp | ((arg0: string) => boolean)>;
157 mode?: string | null;
158}
159export interface RequiredSWDestPartial {
160 swDest: string;
161}
162interface WebpackGenerateSWPartial {
163 importScriptsViaChunks?: Array<string>;
164 /**
165 * @default "service-worker.js"
166 */
167 swDest?: string;
168}
169interface WebpackInjectManifestPartial {
170 /**
171 * @default true
172 */
173 compileSrc?: boolean;
174 swDest?: string;
175 webpackCompilationPlugins?: Array<any>;
176}
177export declare type GenerateSWOptions = BasePartial & GlobPartial & GeneratePartial & RequiredSWDestPartial & OptionalGlobDirectoryPartial;
178export declare type GetManifestOptions = BasePartial & GlobPartial & RequiredGlobDirectoryPartial;
179export declare type InjectManifestOptions = BasePartial & GlobPartial & InjectPartial & RequiredSWDestPartial & RequiredGlobDirectoryPartial;
180export declare type WebpackGenerateSWOptions = BasePartial & WebpackPartial & GeneratePartial & WebpackGenerateSWPartial;
181export declare type WebpackInjectManifestOptions = BasePartial & WebpackPartial & InjectPartial & WebpackInjectManifestPartial;
182export interface GetManifestResult {
183 count: number;
184 manifestEntries: Array<ManifestEntry>;
185 size: number;
186 warnings: Array<string>;
187}
188export declare type BuildResult = Omit<GetManifestResult, 'manifestEntries'> & {
189 filePaths: Array<string>;
190};
191export interface FileDetails {
192 file: string;
193 hash: string;
194 size: number;
195}
196export declare type BuildType = 'dev' | 'prod';
197export interface WorkboxPackageJSON extends PackageJson {
198 workbox?: {
199 browserNamespace?: string;
200 packageType?: string;
201 prodOnly?: boolean;
202 };
203}
204export {};
205
\No newline at end of file