@@ -508,28 +508,46 @@ function debounceCompressUrlMetric() {
508
508
* @typedef {{groups: Array<{url_metrics: Array<UrlMetricDebugData>}>} } CollectionDebugData
509
509
*/
510
510
511
+ /**
512
+ * Args for the detect function.
513
+ *
514
+ * @since 1.0.0
515
+ *
516
+ * @typedef {Object } DetectFunctionArgs
517
+ * @property {string[] } extensionModuleUrls - URLs for extension script modules to import.
518
+ * @property {number } minViewportAspectRatio - Minimum aspect ratio allowed for the viewport.
519
+ * @property {number } maxViewportAspectRatio - Maximum aspect ratio allowed for the viewport.
520
+ * @property {boolean } isDebug - Whether to show debug messages.
521
+ * @property {string } restApiEndpoint - URL for where to send the detection data.
522
+ * @property {string } [restApiNonce] - Nonce for the REST API when the user is logged-in.
523
+ * @property {boolean } gzdecodeAvailable - Whether application/gzip can be sent to the REST API.
524
+ * @property {number } maxUrlMetricSize - Maximum size of the URL Metric to send.
525
+ * @property {string } currentETag - Current ETag.
526
+ * @property {string } currentUrl - Current URL.
527
+ * @property {string } urlMetricSlug - Slug for URL Metric.
528
+ * @property {number|null } cachePurgePostId - Cache purge post ID.
529
+ * @property {string } urlMetricHMAC - HMAC for URL Metric storage.
530
+ * @property {URLMetricGroupStatus[] } urlMetricGroupStatuses - URL Metric group statuses.
531
+ * @property {number } storageLockTTL - The TTL (in seconds) for the URL Metric storage lock.
532
+ * @property {number } freshnessTTL - The freshness age (TTL) for a given URL Metric.
533
+ * @property {string } webVitalsLibrarySrc - The URL for the web-vitals library.
534
+ * @property {CollectionDebugData } [urlMetricGroupCollection] - URL Metric group collection, when in debug mode.
535
+ */
536
+
537
+ /**
538
+ * The detect function.
539
+ *
540
+ * @since 1.0.0
541
+ * @callback DetectFunction
542
+ * @param {DetectFunctionArgs } args - The arguments for the function.
543
+ * @return {Promise<void> }
544
+ */
545
+
511
546
/**
512
547
* Detects the LCP element, loaded images, client viewport, and store for future optimizations.
513
548
*
514
- * @param {Object } args - Args.
515
- * @param {string[] } args.extensionModuleUrls - URLs for extension script modules to import.
516
- * @param {number } args.minViewportAspectRatio - Minimum aspect ratio allowed for the viewport.
517
- * @param {number } args.maxViewportAspectRatio - Maximum aspect ratio allowed for the viewport.
518
- * @param {boolean } args.isDebug - Whether to show debug messages.
519
- * @param {string } args.restApiEndpoint - URL for where to send the detection data.
520
- * @param {string } [args.restApiNonce] - Nonce for the REST API when the user is logged-in.
521
- * @param {boolean } args.gzdecodeAvailable - Whether application/gzip can be sent to the REST API.
522
- * @param {number } args.maxUrlMetricSize - Maximum size of the URL Metric to send.
523
- * @param {string } args.currentETag - Current ETag.
524
- * @param {string } args.currentUrl - Current URL.
525
- * @param {string } args.urlMetricSlug - Slug for URL Metric.
526
- * @param {number|null } args.cachePurgePostId - Cache purge post ID.
527
- * @param {string } args.urlMetricHMAC - HMAC for URL Metric storage.
528
- * @param {URLMetricGroupStatus[] } args.urlMetricGroupStatuses - URL Metric group statuses.
529
- * @param {number } args.storageLockTTL - The TTL (in seconds) for the URL Metric storage lock.
530
- * @param {number } args.freshnessTTL - The freshness age (TTL) for a given URL Metric.
531
- * @param {string } args.webVitalsLibrarySrc - The URL for the web-vitals library.
532
- * @param {CollectionDebugData } [args.urlMetricGroupCollection] - URL Metric group collection, when in debug mode.
549
+ * @type {DetectFunction }
550
+ * @param {DetectFunctionArgs } args - Args.
533
551
*/
534
552
export default async function detect ( {
535
553
minViewportAspectRatio,
0 commit comments