@djangocfg/nextjs 2.1.542 → 2.1.544

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,7 +174,8 @@ export interface SmartScreenshotInput {
174
174
  export function createScreenshot(input: SmartScreenshotInput | string): ScreenshotConfig {
175
175
  // Allow string shorthand
176
176
  const config = typeof input === 'string' ? { src: input } : input;
177
- let { src, width, height, label, form_factor } = config;
177
+ const { src, label, form_factor } = config;
178
+ let { width, height } = config;
178
179
 
179
180
  // Auto-detect image type from extension
180
181
  const ext = src.split('.').pop()?.toLowerCase();
@@ -189,10 +190,12 @@ export function createScreenshot(input: SmartScreenshotInput | string): Screensh
189
190
 
190
191
  // Try to parse dimensions from filename (e.g., "1920x1080.png" or "screenshot-390x844.png")
191
192
  const filename = src.toLowerCase();
192
- const dimensionMatch = filename.match(/(\d{3,4})x(\d{3,4})/);
193
- if (dimensionMatch && !width && !height) {
194
- width = parseInt(dimensionMatch[1], 10);
195
- height = parseInt(dimensionMatch[2], 10);
193
+ // Destructured: `\d{3,4}` cannot match empty, so both groups exist whenever
194
+ // the match does — but only binding them says so without an assertion.
195
+ const [, matchedWidth, matchedHeight] = filename.match(/(\d{3,4})x(\d{3,4})/) ?? [];
196
+ if (matchedWidth && matchedHeight && !width && !height) {
197
+ width = parseInt(matchedWidth, 10);
198
+ height = parseInt(matchedHeight, 10);
196
199
  }
197
200
 
198
201
  // Auto-detect form_factor from filename if not provided
@@ -333,12 +336,12 @@ export function createManifest(config: {
333
336
 
334
337
  // Add screenshots if provided (for Richer PWA Install UI)
335
338
  if (config.screenshots && config.screenshots.length > 0) {
336
- (manifest as any).screenshots = config.screenshots;
339
+ manifest.screenshots = config.screenshots;
337
340
  }
338
341
 
339
342
  // Add protocol handlers if provided
340
343
  if (config.protocol_handlers && config.protocol_handlers.length > 0) {
341
- (manifest as any).protocol_handlers = config.protocol_handlers;
344
+ manifest.protocol_handlers = config.protocol_handlers;
342
345
  }
343
346
 
344
347
  return manifest;
@@ -350,6 +353,6 @@ export function createManifest(config: {
350
353
  *
351
354
  * @deprecated Use createManifest() instead
352
355
  */
353
- export function generateManifest(config: ManifestConfig): Record<string, any> {
356
+ export function generateManifest(config: ManifestConfig): MetadataRoute.Manifest {
354
357
  return createManifest(config)();
355
358
  }
@@ -43,21 +43,23 @@ export function createServiceWorker(options: ServiceWorkerOptions = {}): void {
43
43
  cacheName = 'app-cache-v1',
44
44
  } = options;
45
45
 
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- const sw = self as any;
46
+ // `self` resolves to the DOM lib's `Window` when this file is compiled as part
47
+ // of an app; inside a service worker it is really a ServiceWorkerGlobalScope.
48
+ // Casting once here types every event handler below via the standard overloads.
49
+ const sw = self as unknown as ServiceWorkerGlobalScope;
48
50
 
49
- sw.addEventListener('install', (event: any) => {
51
+ sw.addEventListener('install', (event) => {
50
52
  event.waitUntil(
51
- caches.open(cacheName).then((cache: Cache) => cache.addAll([offlineFallback]))
53
+ caches.open(cacheName).then((cache) => cache.addAll([offlineFallback]))
52
54
  );
53
55
  if (skipWaiting) sw.skipWaiting();
54
56
  });
55
57
 
56
- sw.addEventListener('activate', (event: any) => {
58
+ sw.addEventListener('activate', (event) => {
57
59
  event.waitUntil(
58
60
  caches
59
61
  .keys()
60
- .then((keys: string[]) =>
62
+ .then((keys) =>
61
63
  Promise.all(keys.filter((k) => k !== cacheName).map((k) => caches.delete(k)))
62
64
  )
63
65
  .then(() => {
@@ -66,7 +68,7 @@ export function createServiceWorker(options: ServiceWorkerOptions = {}): void {
66
68
  );
67
69
  });
68
70
 
69
- sw.addEventListener('fetch', (event: any) => {
71
+ sw.addEventListener('fetch', (event) => {
70
72
  const { request } = event;
71
73
  if (request.mode !== 'navigate') return;
72
74
  event.respondWith(
package/src/types.ts CHANGED
@@ -23,6 +23,8 @@ export interface HealthResponse {
23
23
  uptime: number;
24
24
  version?: string;
25
25
  checks?: Record<string, boolean>;
26
+ /** Wall-clock time spent running the configured checks, in milliseconds. */
27
+ durationMs?: number;
26
28
  }
27
29
 
28
30