1 | import { HTTPMethod } from 'workbox-routing';
|
2 | import { Plugin } from 'workbox-background-sync';
|
3 | import { Plugin as Plugin$1 } from 'workbox-broadcast-update';
|
4 | import { Plugin as Plugin$2 } from 'workbox-cacheable-response';
|
5 | import { Plugin as Plugin$3 } from 'workbox-expiration';
|
6 | import { Plugin as Plugin$4 } from 'workbox-range-requests';
|
7 | import { StaleWhileRevalidateOptions, CacheFirstOptions, NetworkFirstOptions, NetworkOnlyOptions, CacheOnlyOptions } from 'workbox-strategies';
|
8 |
|
9 |
|
10 |
|
11 | interface ManifestOptions {
|
12 | |
13 |
|
14 |
|
15 | name: string,
|
16 | |
17 |
|
18 |
|
19 | short_name: string,
|
20 | |
21 |
|
22 |
|
23 | description: string,
|
24 | |
25 |
|
26 |
|
27 | icons: Record<string, any>[],
|
28 | |
29 |
|
30 |
|
31 | start_url: string,
|
32 | |
33 |
|
34 |
|
35 | display: string,
|
36 | |
37 |
|
38 |
|
39 | background_color: string,
|
40 | |
41 |
|
42 |
|
43 | theme_color: string,
|
44 | |
45 |
|
46 |
|
47 | dir: 'ltr' | 'rtl',
|
48 | |
49 |
|
50 |
|
51 | lang: string,
|
52 | |
53 |
|
54 |
|
55 | useWebmanifestExtension: boolean,
|
56 | |
57 |
|
58 |
|
59 | publicPath: string,
|
60 |
|
61 | fileName: string,
|
62 | crossorigin: boolean
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | type OgImageObject = {
|
69 | path?: string,
|
70 | width?: number,
|
71 | height?: number,
|
72 | type?: string
|
73 | }
|
74 |
|
75 | interface MetaOptions extends Partial<ManifestOptions> {
|
76 | |
77 |
|
78 |
|
79 | charset: string,
|
80 | |
81 |
|
82 |
|
83 |
|
84 |
|
85 | viewport: string,
|
86 | |
87 |
|
88 |
|
89 |
|
90 |
|
91 | mobileApp: boolean,
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | mobileAppIOS: boolean,
|
98 | |
99 |
|
100 |
|
101 | appleStatusBarStyle: string,
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 | favicon: boolean,
|
108 | |
109 |
|
110 |
|
111 |
|
112 |
|
113 | name: string,
|
114 | |
115 |
|
116 |
|
117 | title?: string,
|
118 | |
119 |
|
120 |
|
121 |
|
122 |
|
123 | author: string,
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 | description: string,
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 | theme_color: string,
|
136 | |
137 |
|
138 |
|
139 |
|
140 |
|
141 | lang: string,
|
142 | |
143 |
|
144 |
|
145 |
|
146 |
|
147 | ogType: string,
|
148 | |
149 |
|
150 |
|
151 |
|
152 |
|
153 | ogSiteName: string | true,
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 | ogTitle: string | true,
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 | ogDescription: string | true,
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 | ogHost: string | undefined,
|
172 | |
173 |
|
174 |
|
175 |
|
176 |
|
177 | ogImage: boolean | string | OgImageObject,
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 | ogUrl: string | undefined | true,
|
184 | |
185 |
|
186 |
|
187 |
|
188 |
|
189 | twitterCard: string | undefined,
|
190 | |
191 |
|
192 |
|
193 |
|
194 |
|
195 | twitterSite: string | undefined,
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 | twitterCreator: string | undefined,
|
202 | |
203 |
|
204 |
|
205 | nativeUI: boolean
|
206 | }
|
207 |
|
208 | type iOSType = 'ipad' | 'ipadpro9' | 'ipadpro9' | 'ipadpro10' | 'ipadpro12' | 'iphonese' | 'iphone6' | 'iphoneplus' | 'iphonex' | 'iphonexr' | 'iphonexsmax'
|
209 | type iOSSize = [number, number, iOSType]
|
210 |
|
211 | interface IconOptions {
|
212 | |
213 |
|
214 |
|
215 | source: string,
|
216 | |
217 |
|
218 |
|
219 | fileName: string,
|
220 | |
221 |
|
222 |
|
223 |
|
224 | sizes: number[],
|
225 |
|
226 | |
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 | iosSizes: iOSSize[],
|
244 | |
245 |
|
246 |
|
247 | targetDir: string,
|
248 | |
249 |
|
250 |
|
251 |
|
252 |
|
253 | plugin: boolean,
|
254 | |
255 |
|
256 |
|
257 |
|
258 |
|
259 | pluginName: string,
|
260 | |
261 |
|
262 |
|
263 |
|
264 |
|
265 | purpose: string[] | string,
|
266 | |
267 |
|
268 |
|
269 |
|
270 |
|
271 | cacheDir: string,
|
272 |
|
273 | publicPath: string
|
274 | }
|
275 |
|
276 | type CachingStrategy = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate'
|
277 |
|
278 | type StrategyOptions =
|
279 | Omit<StaleWhileRevalidateOptions | CacheFirstOptions | NetworkFirstOptions | NetworkOnlyOptions | CacheOnlyOptions, 'plugins'>
|
280 |
|
281 | type StrategyPluginOf<name, T> = {
|
282 | use: name
|
283 | config: ConstructorParameters<T>[0] | ConstructorParameters<T>
|
284 | }
|
285 |
|
286 | type BackgroundSync = StrategyPluginOf<'BackgroundSync', Plugin>
|
287 | type BroadcastUpdate = StrategyPluginOf<'BroadcastUpdate', Plugin$1>
|
288 | type CacheableResponse = StrategyPluginOf<'CacheableResponse', Plugin$2>
|
289 | type Expiration = StrategyPluginOf<'Expiration', Plugin$3>
|
290 | type RangeRequests = StrategyPluginOf<'RangeRequests', Plugin$4>
|
291 |
|
292 | type StrategyPlugin = BackgroundSync | BroadcastUpdate | CacheableResponse | Expiration | RangeRequests
|
293 |
|
294 | interface RuntimeCaching {
|
295 | urlPattern: string
|
296 | handler?: CachingStrategy
|
297 | method?: HTTPMethod
|
298 | strategyOptions?: StrategyOptions
|
299 | strategyPlugins?: StrategyPlugin[]
|
300 | }
|
301 |
|
302 | interface WorkboxOptions {
|
303 | dev: boolean,
|
304 | workboxVersion: string,
|
305 | workboxURL: string,
|
306 | importScripts: string[],
|
307 | |
308 |
|
309 |
|
310 | autoRegister: boolean,
|
311 | |
312 |
|
313 |
|
314 | enabled: boolean,
|
315 | cacheNames: Record<string, any>,
|
316 | config: Record<string, any>,
|
317 | |
318 |
|
319 |
|
320 | clientsClaim: boolean,
|
321 | |
322 |
|
323 |
|
324 | skipWaiting: boolean,
|
325 | |
326 |
|
327 |
|
328 | offlineAnalytics: boolean,
|
329 | workboxExtensions: string | string[],
|
330 | |
331 |
|
332 |
|
333 | preCaching: string[] | {url: string, revision: string}[],
|
334 | cacheOptions: {
|
335 | |
336 |
|
337 |
|
338 | cacheId: string,
|
339 | |
340 |
|
341 |
|
342 | directoryIndex: string,
|
343 | |
344 |
|
345 |
|
346 | revision: string | undefined
|
347 | },
|
348 | cachingExtensions: string | string[],
|
349 | cleanupOutdatedCaches: boolean,
|
350 | |
351 |
|
352 |
|
353 | offline: boolean,
|
354 | |
355 |
|
356 |
|
357 | offlineStrategy: CachingStrategy,
|
358 | offlinePage: string,
|
359 | offlineAssets: string[],
|
360 | runtimeCaching: RuntimeCaching[],
|
361 | |
362 |
|
363 |
|
364 | cacheAssets: boolean,
|
365 | routingExtensions: string | string[],
|
366 | |
367 |
|
368 |
|
369 | assetsURLPattern: string,
|
370 | |
371 |
|
372 |
|
373 |
|
374 |
|
375 | pagesURLPattern: string,
|
376 | swTemplate: string,
|
377 | swURL: string,
|
378 | swDest: string,
|
379 | |
380 |
|
381 |
|
382 | swScope: string,
|
383 | |
384 |
|
385 |
|
386 | routerBase: string,
|
387 | |
388 |
|
389 |
|
390 | publicPath: string
|
391 | }
|
392 |
|
393 | interface PWAOptions {
|
394 | meta?: Partial<MetaOptions> | false;
|
395 | icon?: Partial<IconOptions> | false;
|
396 | workbox?: Partial<WorkboxOptions> | false;
|
397 | manifest?: Partial<ManifestOptions> | false;
|
398 | }
|
399 | declare function pwa(moduleOptions: PWAOptions): Promise<void>;
|
400 | declare namespace pwa {
|
401 | var meta: {
|
402 | name: string;
|
403 | version: string;
|
404 | };
|
405 | }
|
406 |
|
407 | declare module '@nuxt/types/config/index' {
|
408 | interface NuxtOptions {
|
409 | pwa?: Partial<PWAOptions>;
|
410 | meta?: Partial<MetaOptions> | false;
|
411 | icon?: Partial<IconOptions> | false;
|
412 | workbox?: Partial<WorkboxOptions> | false;
|
413 | manifest?: Partial<ManifestOptions> | false;
|
414 | }
|
415 | }
|
416 |
|
417 | export default pwa;
|