From 664bfa2977df38793d54b625e011b64023d40d38 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 1 Jun 2024 18:48:52 +0200 Subject: [PATCH] Add display of preloaded URLs in ServiceWorker tab (#212) The ServiceWorker tab in the Collector template now includes an option to show preloaded URLs for each caching strategy. This additional information aids in debugging and analysis, by providing visibility into preloaded URLs at a per-strategy level. --- phpstan-baseline.neon | 47 ++++++++++++++++++- phpunit.xml.dist | 1 + .../Collector/serviceworker-tab.html.twig | 16 ++++++- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0e60f4e..27b867b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -20,6 +20,11 @@ parameters: count: 1 path: src/CachingStrategy/AssetCache.php + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/CachingStrategy/BackgroundSync.php + - message: "#^Only iterables can be unpacked, mixed given in argument \\#1\\.$#" count: 1 @@ -35,6 +40,16 @@ parameters: count: 2 path: src/CachingStrategy/FontCache.php + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/CachingStrategy/PreloadUrlsGeneratorManager.php + + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/CachingStrategy/ResourceCaches.php + - message: "#^Only iterables can be unpacked, mixed given in argument \\#1\\.$#" count: 1 @@ -120,6 +135,16 @@ parameters: count: 1 path: src/Command/CreateScreenshotCommand.php + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/Command/ListCacheStrategiesCommand.php + + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/DataCollector/PwaCollector.php + - message: "#^Class SpomkyLabs\\\\PwaBundle\\\\Dto\\\\BackgroundSync has an uninitialized property \\$forceSyncFallback\\. Give it default value or assign it in the constructor\\.$#" count: 1 @@ -580,6 +605,16 @@ parameters: count: 1 path: src/Service/FaviconsCompiler.php + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/Service/ServiceWorkerCompiler.php + + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/ServiceWorkerRule/AppendCacheStrategies.php + - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 1 @@ -593,4 +628,14 @@ parameters: - message: "#^Method SpomkyLabs\\\\PwaBundle\\\\SpomkyLabsPwaBundle\\:\\:loadExtension\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#" count: 1 - path: src/SpomkyLabsPwaBundle.php \ No newline at end of file + path: src/SpomkyLabsPwaBundle.php + + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/Subscriber/FileCompileEventListener.php + + - + message: "#^Attribute class Symfony\\\\Component\\\\DependencyInjection\\\\Attribute\\\\TaggedIterator is deprecated\\: since Symfony 7\\.1, use \\{@see AutowireIterator\\} instead\\.$#" + count: 1 + path: src/Subscriber/PwaDevServerSubscriber.php \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4772da6..e286cda 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,6 +18,7 @@ + diff --git a/templates/Collector/serviceworker-tab.html.twig b/templates/Collector/serviceworker-tab.html.twig index e93c3e9..4c57b33 100644 --- a/templates/Collector/serviceworker-tab.html.twig +++ b/templates/Collector/serviceworker-tab.html.twig @@ -128,7 +128,7 @@ - {% for cachingStrategy in collector.cachingStrategies %} + {% for id, cachingStrategy in collector.cachingStrategies %} {{ cachingStrategy.getName() }} @@ -163,6 +163,20 @@ {% endif %} + {% if preloadedUrls > 0 %} + + +
+ + Show preloaded URLs + +
+ {{ dump(cachingStrategy.preloadUrls) }} +
+
+ + + {% endif %} {% endfor %}