From 4e58ffb8860923a6ef0124428d2ebb4a5b8f0878 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sun, 17 Mar 2024 21:06:06 +0100 Subject: [PATCH] Better Cache Strategy Support --- phpstan-baseline.neon | 96 +++++++++---------- .../Rule => CachingStrategy}/AssetCache.php | 7 +- .../BackgroundSync.php | 9 +- .../CacheStrategy.php | 2 +- .../Rule => CachingStrategy}/FontCache.php | 9 +- .../GoogleFontCache.php | 9 +- .../HasCacheStrategies.php | 2 +- .../Rule => CachingStrategy}/ImageCache.php | 9 +- .../ManifestCache.php | 5 +- .../ResourceCaches.php} | 44 ++++----- .../WorkboxCacheStrategy.php | 6 +- src/Command/ListCacheStrategiesCommand.php | 6 +- src/Dto/Workbox.php | 4 +- .../DestinationMatchCallbackHandler.php | 2 +- .../ExactPathnameMatchCallbackHandler.php | 2 +- .../MatchCallbackHandler.php | 2 +- .../NavigationMatchCallbackHandler.php | 2 +- .../OriginMatchCallbackHandler.php | 2 +- .../PathnameEndsWithMatchCallbackHandler.php | 2 +- ...PathnameStartsWithMatchCallbackHandler.php | 2 +- .../RegexMatchCallbackHandler.php | 2 +- .../RouteMatchCallbackHandler.php | 28 ++++++ .../config/definition/service_worker.php | 17 ++-- src/Resources/config/services.php | 13 ++- src/Service/ServiceWorkerCompiler.php | 2 +- .../AppendCacheStrategies.php | 6 +- .../Rule => ServiceWorkerRule}/ClearCache.php | 2 +- .../OfflineFallback.php | 2 +- .../ServiceWorkerRule.php | 2 +- .../SkipWaiting.php | 2 +- .../WindowsWidgets.php | 2 +- .../WorkboxImport.php | 2 +- .../BackgroundSyncPlugin.php | 2 +- .../BroadcastUpdatePlugin.php | 2 +- .../Plugin => WorkboxPlugin}/CachePlugin.php | 2 +- .../CacheableResponsePlugin.php | 2 +- .../ExpirationPlugin.php | 2 +- .../RangeRequestsPlugin.php | 2 +- tests/config.php | 2 +- 39 files changed, 163 insertions(+), 153 deletions(-) rename src/{Service/Rule => CachingStrategy}/AssetCache.php (91%) rename src/{Service/Rule => CachingStrategy}/BackgroundSync.php (84%) rename src/{Service => CachingStrategy}/CacheStrategy.php (94%) rename src/{Service/Rule => CachingStrategy}/FontCache.php (88%) rename src/{Service/Rule => CachingStrategy}/GoogleFontCache.php (83%) rename src/{Service => CachingStrategy}/HasCacheStrategies.php (77%) rename src/{Service/Rule => CachingStrategy}/ImageCache.php (83%) rename src/{Service/Rule => CachingStrategy}/ManifestCache.php (88%) rename src/{Service/Rule/PageCaches.php => CachingStrategy/ResourceCaches.php} (58%) rename src/{Service => CachingStrategy}/WorkboxCacheStrategy.php (93%) rename src/{Service => }/MatchCallbackHandler/DestinationMatchCallbackHandler.php (87%) rename src/{Service => }/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php (87%) rename src/{Service => }/MatchCallbackHandler/MatchCallbackHandler.php (75%) rename src/{Service => }/MatchCallbackHandler/NavigationMatchCallbackHandler.php (85%) rename src/{Service => }/MatchCallbackHandler/OriginMatchCallbackHandler.php (87%) rename src/{Service => }/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php (87%) rename src/{Service => }/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php (87%) rename src/{Service => }/MatchCallbackHandler/RegexMatchCallbackHandler.php (86%) create mode 100644 src/MatchCallbackHandler/RouteMatchCallbackHandler.php rename src/{Service/Rule => ServiceWorkerRule}/AppendCacheStrategies.php (88%) rename src/{Service/Rule => ServiceWorkerRule}/ClearCache.php (95%) rename src/{Service/Rule => ServiceWorkerRule}/OfflineFallback.php (97%) rename src/{Service/Rule => ServiceWorkerRule}/ServiceWorkerRule.php (70%) rename src/{Service/Rule => ServiceWorkerRule}/SkipWaiting.php (93%) rename src/{Service/Rule => ServiceWorkerRule}/WindowsWidgets.php (98%) rename src/{Service/Rule => ServiceWorkerRule}/WorkboxImport.php (95%) rename src/{Service/Plugin => WorkboxPlugin}/BackgroundSyncPlugin.php (97%) rename src/{Service/Plugin => WorkboxPlugin}/BroadcastUpdatePlugin.php (93%) rename src/{Service/Plugin => WorkboxPlugin}/CachePlugin.php (86%) rename src/{Service/Plugin => WorkboxPlugin}/CacheableResponsePlugin.php (94%) rename src/{Service/Plugin => WorkboxPlugin}/ExpirationPlugin.php (91%) rename src/{Service/Plugin => WorkboxPlugin}/RangeRequestsPlugin.php (87%) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5fd7404..1df498e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,35 @@ parameters: ignoreErrors: + - + message: "#^Parameter \\#1 \\$name of static method SpomkyLabs\\\\PwaBundle\\\\CachingStrategy\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: src/CachingStrategy/AssetCache.php + + - + message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\CachingStrategy\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" + count: 1 + path: src/CachingStrategy/AssetCache.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" + count: 1 + path: src/CachingStrategy/FontCache.php + + - + message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\CachingStrategy\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" + count: 1 + path: src/CachingStrategy/FontCache.php + + - + message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\CachingStrategy\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" + count: 1 + path: src/CachingStrategy/ResourceCaches.php + + - + message: "#^Part \\$this\\-\\>options\\['networkTimeoutSeconds'\\] \\(mixed\\) of encapsed string cannot be cast to string\\.$#" + count: 1 + path: src/CachingStrategy/WorkboxCacheStrategy.php + - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -346,7 +376,7 @@ parameters: path: src/Dto/Workbox.php - - message: "#^Class SpomkyLabs\\\\PwaBundle\\\\Dto\\\\Workbox has an uninitialized property \\$pageCaches\\. Give it default value or assign it in the constructor\\.$#" + message: "#^Class SpomkyLabs\\\\PwaBundle\\\\Dto\\\\Workbox has an uninitialized property \\$resourceCaches\\. Give it default value or assign it in the constructor\\.$#" count: 1 path: src/Dto/Workbox.php @@ -576,7 +606,7 @@ parameters: path: src/Resources/config/definition/service_worker.php - - message: "#^Cannot access offset 'page_caches' on mixed\\.$#" + message: "#^Cannot access offset 'resource_caches' on mixed\\.$#" count: 2 path: src/Resources/config/definition/service_worker.php @@ -650,72 +680,42 @@ parameters: count: 1 path: src/Resources/config/definition/web_client.php - - - message: "#^Part \\$broadcastChannel \\(mixed\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: src/Service/Plugin/BackgroundSyncPlugin.php - - - - message: "#^Part \\$maxRetentionTime \\(mixed\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: src/Service/Plugin/BackgroundSyncPlugin.php - - - - message: "#^Part \\$queueName \\(mixed\\) of encapsed string cannot be cast to string\\.$#" - count: 2 - path: src/Service/Plugin/BackgroundSyncPlugin.php - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 1 - path: src/Service/Rule/AppendCacheStrategies.php - - - - message: "#^Parameter \\#1 \\$name of static method SpomkyLabs\\\\PwaBundle\\\\Service\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: src/Service/Rule/AssetCache.php - - - - message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\Service\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" - count: 1 - path: src/Service/Rule/AssetCache.php + path: src/ServiceWorkerRule/AppendCacheStrategies.php - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: src/Service/Rule/FontCache.php - - - - message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\Service\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" + message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#" count: 1 - path: src/Service/Rule/FontCache.php + path: src/ServiceWorkerRule/OfflineFallback.php - - message: "#^Strict comparison using \\=\\=\\= between int\\<1, max\\> and 0 will always evaluate to false\\.$#" + message: "#^Method SpomkyLabs\\\\PwaBundle\\\\SpomkyLabsPwaBundle\\:\\:loadExtension\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#" count: 1 - path: src/Service/Rule/OfflineFallback.php + path: src/SpomkyLabsPwaBundle.php - - message: "#^Parameter \\#8 \\$preloadUrls of static method SpomkyLabs\\\\PwaBundle\\\\Service\\\\WorkboxCacheStrategy\\:\\:create\\(\\) expects array\\, mixed given\\.$#" + message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\ManifestCompileEventListener\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#" count: 1 - path: src/Service/Rule/PageCaches.php + path: src/Subscriber/ManifestCompileEventListener.php - - message: "#^Part \\$this\\-\\>options\\['networkTimeoutSeconds'\\] \\(mixed\\) of encapsed string cannot be cast to string\\.$#" + message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\PwaDevServerSubscriber\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#" count: 1 - path: src/Service/WorkboxCacheStrategy.php + path: src/Subscriber/PwaDevServerSubscriber.php - - message: "#^Method SpomkyLabs\\\\PwaBundle\\\\SpomkyLabsPwaBundle\\:\\:loadExtension\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#" + message: "#^Part \\$broadcastChannel \\(mixed\\) of encapsed string cannot be cast to string\\.$#" count: 1 - path: src/SpomkyLabsPwaBundle.php + path: src/WorkboxPlugin/BackgroundSyncPlugin.php - - message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\ManifestCompileEventListener\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#" + message: "#^Part \\$maxRetentionTime \\(mixed\\) of encapsed string cannot be cast to string\\.$#" count: 1 - path: src/Subscriber/ManifestCompileEventListener.php + path: src/WorkboxPlugin/BackgroundSyncPlugin.php - - message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\PwaDevServerSubscriber\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Subscriber/PwaDevServerSubscriber.php \ No newline at end of file + message: "#^Part \\$queueName \\(mixed\\) of encapsed string cannot be cast to string\\.$#" + count: 2 + path: src/WorkboxPlugin/BackgroundSyncPlugin.php \ No newline at end of file diff --git a/src/Service/Rule/AssetCache.php b/src/CachingStrategy/AssetCache.php similarity index 91% rename from src/Service/Rule/AssetCache.php rename to src/CachingStrategy/AssetCache.php index 5d7c110..8cd8f5a 100644 --- a/src/Service/Rule/AssetCache.php +++ b/src/CachingStrategy/AssetCache.php @@ -2,14 +2,11 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\Plugin\ExpirationPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolverInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; diff --git a/src/Service/Rule/BackgroundSync.php b/src/CachingStrategy/BackgroundSync.php similarity index 84% rename from src/Service/Rule/BackgroundSync.php rename to src/CachingStrategy/BackgroundSync.php index f93ae10..9316a8e 100644 --- a/src/Service/Rule/BackgroundSync.php +++ b/src/CachingStrategy/BackgroundSync.php @@ -2,15 +2,12 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\MatchCallbackHandler\MatchCallbackHandler; -use SpomkyLabs\PwaBundle\Service\Plugin\BackgroundSyncPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\MatchCallbackHandler\MatchCallbackHandler; +use SpomkyLabs\PwaBundle\WorkboxPlugin\BackgroundSyncPlugin; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; final readonly class BackgroundSync implements HasCacheStrategies diff --git a/src/Service/CacheStrategy.php b/src/CachingStrategy/CacheStrategy.php similarity index 94% rename from src/Service/CacheStrategy.php rename to src/CachingStrategy/CacheStrategy.php index d20a5f8..bc4f459 100644 --- a/src/Service/CacheStrategy.php +++ b/src/CachingStrategy/CacheStrategy.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service; +namespace SpomkyLabs\PwaBundle\CachingStrategy; abstract readonly class CacheStrategy { diff --git a/src/Service/Rule/FontCache.php b/src/CachingStrategy/FontCache.php similarity index 88% rename from src/Service/Rule/FontCache.php rename to src/CachingStrategy/FontCache.php index 4c0682b..050eb41 100644 --- a/src/Service/Rule/FontCache.php +++ b/src/CachingStrategy/FontCache.php @@ -2,15 +2,12 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\Plugin\CacheableResponsePlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\ExpirationPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CacheableResponsePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Serializer\Encoder\JsonEncode; diff --git a/src/Service/Rule/GoogleFontCache.php b/src/CachingStrategy/GoogleFontCache.php similarity index 83% rename from src/Service/Rule/GoogleFontCache.php rename to src/CachingStrategy/GoogleFontCache.php index fe4031b..12db19e 100644 --- a/src/Service/Rule/GoogleFontCache.php +++ b/src/CachingStrategy/GoogleFontCache.php @@ -2,15 +2,12 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\Plugin\CacheableResponsePlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\ExpirationPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CacheableResponsePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin; final readonly class GoogleFontCache implements HasCacheStrategies { diff --git a/src/Service/HasCacheStrategies.php b/src/CachingStrategy/HasCacheStrategies.php similarity index 77% rename from src/Service/HasCacheStrategies.php rename to src/CachingStrategy/HasCacheStrategies.php index be5f89d..0444ec5 100644 --- a/src/Service/HasCacheStrategies.php +++ b/src/CachingStrategy/HasCacheStrategies.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service; +namespace SpomkyLabs\PwaBundle\CachingStrategy; interface HasCacheStrategies { diff --git a/src/Service/Rule/ImageCache.php b/src/CachingStrategy/ImageCache.php similarity index 83% rename from src/Service/Rule/ImageCache.php rename to src/CachingStrategy/ImageCache.php index 5426917..b5809e3 100644 --- a/src/Service/Rule/ImageCache.php +++ b/src/CachingStrategy/ImageCache.php @@ -2,15 +2,12 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\Plugin\CacheableResponsePlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\ExpirationPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CacheableResponsePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin; use Symfony\Component\AssetMapper\Path\PublicAssetsPathResolverInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; diff --git a/src/Service/Rule/ManifestCache.php b/src/CachingStrategy/ManifestCache.php similarity index 88% rename from src/Service/Rule/ManifestCache.php rename to src/CachingStrategy/ManifestCache.php index 11623d9..bfa572b 100644 --- a/src/Service/Rule/ManifestCache.php +++ b/src/CachingStrategy/ManifestCache.php @@ -2,13 +2,10 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; use Symfony\Component\DependencyInjection\Attribute\Autowire; use const PHP_EOL; diff --git a/src/Service/Rule/PageCaches.php b/src/CachingStrategy/ResourceCaches.php similarity index 58% rename from src/Service/Rule/PageCaches.php rename to src/CachingStrategy/ResourceCaches.php index f461786..6ccb90a 100644 --- a/src/Service/Rule/PageCaches.php +++ b/src/CachingStrategy/ResourceCaches.php @@ -2,18 +2,15 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\CachingStrategy; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; -use SpomkyLabs\PwaBundle\Service\CacheStrategy; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\MatchCallbackHandler\MatchCallbackHandler; -use SpomkyLabs\PwaBundle\Service\Plugin\BroadcastUpdatePlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\CacheableResponsePlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\ExpirationPlugin; -use SpomkyLabs\PwaBundle\Service\Plugin\RangeRequestsPlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\MatchCallbackHandler\MatchCallbackHandler; +use SpomkyLabs\PwaBundle\WorkboxPlugin\BroadcastUpdatePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CacheableResponsePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\RangeRequestsPlugin; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; use Symfony\Component\Serializer\Encoder\JsonEncode; @@ -23,7 +20,7 @@ use const JSON_UNESCAPED_SLASHES; use const JSON_UNESCAPED_UNICODE; -final readonly class PageCaches implements HasCacheStrategies +final readonly class ResourceCaches implements HasCacheStrategies { private int $jsonOptions; @@ -51,41 +48,42 @@ public function __construct( public function getCacheStrategies(): array { $strategies = []; - foreach ($this->workbox->pageCaches as $id => $pageCache) { - $routes = $this->serializer->serialize($pageCache->urls, 'json', [ + foreach ($this->workbox->resourceCaches as $id => $resourceCache) { + $routes = $this->serializer->serialize($resourceCache->urls, 'json', [ JsonEncode::OPTIONS => $this->jsonOptions, ]); $url = json_decode($routes, true, 512, JSON_THROW_ON_ERROR); - $cacheName = $pageCache->cacheName ?? sprintf('page-cache-%d', $id); + + $cacheName = $resourceCache->cacheName ?? sprintf('page-cache-%d', $id); $plugins = [ CacheableResponsePlugin::create( - $pageCache->cacheableResponseStatuses, - $pageCache->cacheableResponseHeaders + $resourceCache->cacheableResponseStatuses, + $resourceCache->cacheableResponseHeaders ), ]; - if ($pageCache->broadcast === true && $pageCache->strategy === CacheStrategy::STRATEGY_STALE_WHILE_REVALIDATE) { - $plugins[] = BroadcastUpdatePlugin::create($pageCache->broadcastHeaders); + if ($resourceCache->broadcast === true && $resourceCache->strategy === CacheStrategy::STRATEGY_STALE_WHILE_REVALIDATE) { + $plugins[] = BroadcastUpdatePlugin::create($resourceCache->broadcastHeaders); } - if ($pageCache->rangeRequests === true && $pageCache->strategy !== CacheStrategy::STRATEGY_NETWORK_ONLY) { + if ($resourceCache->rangeRequests === true && $resourceCache->strategy !== CacheStrategy::STRATEGY_NETWORK_ONLY) { $plugins[] = RangeRequestsPlugin::create(); } - if ($pageCache->maxEntries !== null || $pageCache->maxAgeInSeconds() !== null) { - $plugins[] = ExpirationPlugin::create($pageCache->maxEntries, $pageCache->maxAgeInSeconds()); + if ($resourceCache->maxEntries !== null || $resourceCache->maxAgeInSeconds() !== null) { + $plugins[] = ExpirationPlugin::create($resourceCache->maxEntries, $resourceCache->maxAgeInSeconds()); } $strategies[] = WorkboxCacheStrategy::create( $cacheName, - $pageCache->strategy, - $this->prepareMatchCallback($pageCache->matchCallback), + $resourceCache->strategy, + $this->prepareMatchCallback($resourceCache->matchCallback), $this->workbox->enabled, true, null, $plugins, $url, [ - 'networkTimeoutSeconds' => $pageCache->networkTimeout, + 'networkTimeoutSeconds' => $resourceCache->networkTimeout, ] ); } diff --git a/src/Service/WorkboxCacheStrategy.php b/src/CachingStrategy/WorkboxCacheStrategy.php similarity index 93% rename from src/Service/WorkboxCacheStrategy.php rename to src/CachingStrategy/WorkboxCacheStrategy.php index f45b5d5..892fb31 100644 --- a/src/Service/WorkboxCacheStrategy.php +++ b/src/CachingStrategy/WorkboxCacheStrategy.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service; +namespace SpomkyLabs\PwaBundle\CachingStrategy; -use SpomkyLabs\PwaBundle\Service\Plugin\CachePlugin; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CachePlugin; use function in_array; final readonly class WorkboxCacheStrategy extends CacheStrategy @@ -73,7 +73,7 @@ public function render(string $cacheObjectName, int $jsonOptions = 0): string } $cacheName = ''; if ($this->strategy !== self::STRATEGY_NETWORK_ONLY) { - $cacheName = "cacheName: '{$cacheName}',"; + $cacheName = sprintf("cacheName: '%s',", $this->name ?? $cacheObjectName); } $plugins = sprintf('[%s]', implode(', ', array_map( fn (CachePlugin $plugin) => $plugin->render($jsonOptions), diff --git a/src/Command/ListCacheStrategiesCommand.php b/src/Command/ListCacheStrategiesCommand.php index d563859..f20efd2 100644 --- a/src/Command/ListCacheStrategiesCommand.php +++ b/src/Command/ListCacheStrategiesCommand.php @@ -4,9 +4,9 @@ namespace SpomkyLabs\PwaBundle\Command; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; -use SpomkyLabs\PwaBundle\Service\Plugin\CachePlugin; -use SpomkyLabs\PwaBundle\Service\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\CachingStrategy\HasCacheStrategies; +use SpomkyLabs\PwaBundle\CachingStrategy\WorkboxCacheStrategy; +use SpomkyLabs\PwaBundle\WorkboxPlugin\CachePlugin; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Dto/Workbox.php b/src/Dto/Workbox.php index 0e25b10..be21a54 100644 --- a/src/Dto/Workbox.php +++ b/src/Dto/Workbox.php @@ -30,8 +30,8 @@ final class Workbox /** * @var array */ - #[SerializedName('page_caches')] - public array $pageCaches; + #[SerializedName('resource_caches')] + public array $resourceCaches; #[SerializedName('asset_cache')] public AssetCache $assetCache; diff --git a/src/Service/MatchCallbackHandler/DestinationMatchCallbackHandler.php b/src/MatchCallbackHandler/DestinationMatchCallbackHandler.php similarity index 87% rename from src/Service/MatchCallbackHandler/DestinationMatchCallbackHandler.php rename to src/MatchCallbackHandler/DestinationMatchCallbackHandler.php index f52304d..f97c9e8 100644 --- a/src/Service/MatchCallbackHandler/DestinationMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/DestinationMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class DestinationMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php b/src/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php similarity index 87% rename from src/Service/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php rename to src/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php index 8752ac8..ae09686 100644 --- a/src/Service/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/ExactPathnameMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class ExactPathnameMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/MatchCallbackHandler.php b/src/MatchCallbackHandler/MatchCallbackHandler.php similarity index 75% rename from src/Service/MatchCallbackHandler/MatchCallbackHandler.php rename to src/MatchCallbackHandler/MatchCallbackHandler.php index 0f3e9a3..0006374 100644 --- a/src/Service/MatchCallbackHandler/MatchCallbackHandler.php +++ b/src/MatchCallbackHandler/MatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; interface MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/NavigationMatchCallbackHandler.php b/src/MatchCallbackHandler/NavigationMatchCallbackHandler.php similarity index 85% rename from src/Service/MatchCallbackHandler/NavigationMatchCallbackHandler.php rename to src/MatchCallbackHandler/NavigationMatchCallbackHandler.php index 9c3f084..e38bc4b 100644 --- a/src/Service/MatchCallbackHandler/NavigationMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/NavigationMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class NavigationMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/OriginMatchCallbackHandler.php b/src/MatchCallbackHandler/OriginMatchCallbackHandler.php similarity index 87% rename from src/Service/MatchCallbackHandler/OriginMatchCallbackHandler.php rename to src/MatchCallbackHandler/OriginMatchCallbackHandler.php index 526a021..e0f49bf 100644 --- a/src/Service/MatchCallbackHandler/OriginMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/OriginMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class OriginMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php b/src/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php similarity index 87% rename from src/Service/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php rename to src/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php index 457974c..3aa64ac 100644 --- a/src/Service/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/PathnameEndsWithMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class PathnameEndsWithMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php b/src/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php similarity index 87% rename from src/Service/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php rename to src/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php index 374c438..9857edb 100644 --- a/src/Service/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/PathnameStartsWithMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class PathnameStartsWithMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/Service/MatchCallbackHandler/RegexMatchCallbackHandler.php b/src/MatchCallbackHandler/RegexMatchCallbackHandler.php similarity index 86% rename from src/Service/MatchCallbackHandler/RegexMatchCallbackHandler.php rename to src/MatchCallbackHandler/RegexMatchCallbackHandler.php index 5389684..3dbb669 100644 --- a/src/Service/MatchCallbackHandler/RegexMatchCallbackHandler.php +++ b/src/MatchCallbackHandler/RegexMatchCallbackHandler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\MatchCallbackHandler; +namespace SpomkyLabs\PwaBundle\MatchCallbackHandler; final readonly class RegexMatchCallbackHandler implements MatchCallbackHandler { diff --git a/src/MatchCallbackHandler/RouteMatchCallbackHandler.php b/src/MatchCallbackHandler/RouteMatchCallbackHandler.php new file mode 100644 index 0000000..164032a --- /dev/null +++ b/src/MatchCallbackHandler/RouteMatchCallbackHandler.php @@ -0,0 +1,28 @@ +router->generate($routeName); + + return sprintf("({url}) => url.pathname === '%s'", $route); + } +} diff --git a/src/Resources/config/definition/service_worker.php b/src/Resources/config/definition/service_worker.php index ee013d7..9aca1ea 100644 --- a/src/Resources/config/definition/service_worker.php +++ b/src/Resources/config/definition/service_worker.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use SpomkyLabs\PwaBundle\Service\CacheStrategy; +use SpomkyLabs\PwaBundle\CachingStrategy\CacheStrategy; use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; return static function (DefinitionConfigurator $definition): void { @@ -98,11 +98,10 @@ ->beforeNormalization() ->ifTrue(static fn (mixed $v): bool => true) ->then(static function (mixed $v): array { - if (isset($v['page_caches'])) { + if (isset($v['resource_caches'])) { return $v; } - - $v['page_caches'][] = [ + $v['resource_caches'][] = [ 'match_callback' => 'navigate', 'preload_urls' => $v['warm_cache_urls'] ?? [], 'cache_name' => $v['page_cache_name'] ?? 'pages', @@ -269,7 +268,7 @@ ->end() ->end() ->end() - ->arrayNode('page_caches') + ->arrayNode('resource_caches') ->treatNullLike([]) ->treatFalseLike([]) ->treatTrueLike([]) @@ -287,7 +286,7 @@ ->integerNode('network_timeout') ->defaultValue(3) ->info( - 'The network timeout in seconds before cache is called (for "NetworkFirst" strategy only).' + 'The network timeout in seconds before cache is called (for "NetworkFirst" and "NetworkOnly" strategies).' ) ->example([1, 2, 5]) ->end() @@ -453,7 +452,7 @@ ->setDeprecated( 'spomky-labs/phpwa', '1.1.0', - 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.page_caches[].cache_name" instead.' + 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.resource_caches[].cache_name" instead.' ) ->end() ->scalarNode('asset_cache_name') @@ -545,7 +544,7 @@ ->setDeprecated( 'spomky-labs/phpwa', '1.1.0', - 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.page_caches[].network_timeout" instead.' + 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.resource_caches[].network_timeout" instead.' ) ->end() ->arrayNode('warm_cache_urls') @@ -556,7 +555,7 @@ ->setDeprecated( 'spomky-labs/phpwa', '1.1.0', - 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.page_caches[].urls" instead.' + 'The "%node%" option is deprecated and will be removed in 2.0.0. Please use "pwa.serviceworker.workbox.resource_caches[].urls" instead.' ) ->arrayPrototype() ->beforeNormalization() diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php index cff0c8f..b5fea92 100644 --- a/src/Resources/config/services.php +++ b/src/Resources/config/services.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Facebook\WebDriver\WebDriverDimension; +use SpomkyLabs\PwaBundle\CachingStrategy\HasCacheStrategies; use SpomkyLabs\PwaBundle\Command\CreateIconsCommand; use SpomkyLabs\PwaBundle\Command\CreateScreenshotCommand; use SpomkyLabs\PwaBundle\Command\ListCacheStrategiesCommand; @@ -10,12 +11,11 @@ use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\ImageProcessor\GDImageProcessor; use SpomkyLabs\PwaBundle\ImageProcessor\ImagickImageProcessor; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; +use SpomkyLabs\PwaBundle\MatchCallbackHandler\MatchCallbackHandler; use SpomkyLabs\PwaBundle\Service\ManifestBuilder; -use SpomkyLabs\PwaBundle\Service\MatchCallbackHandler\MatchCallbackHandler; -use SpomkyLabs\PwaBundle\Service\Rule\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Service\ServiceWorkerBuilder; use SpomkyLabs\PwaBundle\Service\ServiceWorkerCompiler; +use SpomkyLabs\PwaBundle\ServiceWorkerRule\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Subscriber\ManifestCompileEventListener; use SpomkyLabs\PwaBundle\Subscriber\PwaDevServerSubscriber; use SpomkyLabs\PwaBundle\Subscriber\ServiceWorkerCompileEventListener; @@ -110,15 +110,18 @@ ; /*** Service Worker Compiler Rules ***/ + $container->load('SpomkyLabs\\PwaBundle\\ServiceWorkerRule\\', '../../ServiceWorkerRule/*'); $container->instanceof(ServiceWorkerRule::class) ->tag('spomky_labs_pwa.service_worker_rule') ; + + $container->load('SpomkyLabs\\PwaBundle\\CachingStrategy\\', '../../CachingStrategy/*'); $container->instanceof(HasCacheStrategies::class) ->tag('spomky_labs_pwa.cache_strategy') ; - $container->load('SpomkyLabs\\PwaBundle\\Service\\Rule\\', '../../Service/Rule/*'); + + $container->load('SpomkyLabs\\PwaBundle\\MatchCallbackHandler\\', '../../MatchCallbackHandler/*'); $container->instanceof(MatchCallbackHandler::class) ->tag('spomky_labs_pwa.match_callback_handler') ; - $container->load('SpomkyLabs\\PwaBundle\\Service\\MatchCallbackHandler\\', '../../Service/MatchCallbackHandler/*'); }; diff --git a/src/Service/ServiceWorkerCompiler.php b/src/Service/ServiceWorkerCompiler.php index bde453c..de43590 100644 --- a/src/Service/ServiceWorkerCompiler.php +++ b/src/Service/ServiceWorkerCompiler.php @@ -5,7 +5,7 @@ namespace SpomkyLabs\PwaBundle\Service; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; -use SpomkyLabs\PwaBundle\Service\Rule\ServiceWorkerRule; +use SpomkyLabs\PwaBundle\ServiceWorkerRule\ServiceWorkerRule; use Symfony\Component\AssetMapper\AssetMapperInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; diff --git a/src/Service/Rule/AppendCacheStrategies.php b/src/ServiceWorkerRule/AppendCacheStrategies.php similarity index 88% rename from src/Service/Rule/AppendCacheStrategies.php rename to src/ServiceWorkerRule/AppendCacheStrategies.php index 8bdd76a..511b07f 100644 --- a/src/Service/Rule/AppendCacheStrategies.php +++ b/src/ServiceWorkerRule/AppendCacheStrategies.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; -use SpomkyLabs\PwaBundle\Service\HasCacheStrategies; +use SpomkyLabs\PwaBundle\CachingStrategy\HasCacheStrategies; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; use const JSON_PRETTY_PRINT; @@ -42,7 +42,7 @@ public function process(string $body): string } $body .= PHP_EOL . PHP_EOL . trim($strategy->render( - sprintf('cacheStrategy_%d_%d', $idCacheStrategy, $idStrategy), + sprintf('cache_%d_%d', $idCacheStrategy, $idStrategy), $this->jsonOptions )); } diff --git a/src/Service/Rule/ClearCache.php b/src/ServiceWorkerRule/ClearCache.php similarity index 95% rename from src/Service/Rule/ClearCache.php rename to src/ServiceWorkerRule/ClearCache.php index d41f25e..a0cadbb 100644 --- a/src/Service/Rule/ClearCache.php +++ b/src/ServiceWorkerRule/ClearCache.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; diff --git a/src/Service/Rule/OfflineFallback.php b/src/ServiceWorkerRule/OfflineFallback.php similarity index 97% rename from src/Service/Rule/OfflineFallback.php rename to src/ServiceWorkerRule/OfflineFallback.php index 07b58b9..976452f 100644 --- a/src/Service/Rule/OfflineFallback.php +++ b/src/ServiceWorkerRule/OfflineFallback.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; diff --git a/src/Service/Rule/ServiceWorkerRule.php b/src/ServiceWorkerRule/ServiceWorkerRule.php similarity index 70% rename from src/Service/Rule/ServiceWorkerRule.php rename to src/ServiceWorkerRule/ServiceWorkerRule.php index 76c1154..fa3f164 100644 --- a/src/Service/Rule/ServiceWorkerRule.php +++ b/src/ServiceWorkerRule/ServiceWorkerRule.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; interface ServiceWorkerRule { diff --git a/src/Service/Rule/SkipWaiting.php b/src/ServiceWorkerRule/SkipWaiting.php similarity index 93% rename from src/Service/Rule/SkipWaiting.php rename to src/ServiceWorkerRule/SkipWaiting.php index 310a6ed..b976fef 100644 --- a/src/Service/Rule/SkipWaiting.php +++ b/src/ServiceWorkerRule/SkipWaiting.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use const PHP_EOL; diff --git a/src/Service/Rule/WindowsWidgets.php b/src/ServiceWorkerRule/WindowsWidgets.php similarity index 98% rename from src/Service/Rule/WindowsWidgets.php rename to src/ServiceWorkerRule/WindowsWidgets.php index 13888a2..c3d2314 100644 --- a/src/Service/Rule/WindowsWidgets.php +++ b/src/ServiceWorkerRule/WindowsWidgets.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Dto\Manifest; use Symfony\Component\Serializer\Encoder\JsonEncode; diff --git a/src/Service/Rule/WorkboxImport.php b/src/ServiceWorkerRule/WorkboxImport.php similarity index 95% rename from src/Service/Rule/WorkboxImport.php rename to src/ServiceWorkerRule/WorkboxImport.php index d424c19..7d22728 100644 --- a/src/Service/Rule/WorkboxImport.php +++ b/src/ServiceWorkerRule/WorkboxImport.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Rule; +namespace SpomkyLabs\PwaBundle\ServiceWorkerRule; use SpomkyLabs\PwaBundle\Dto\ServiceWorker; use SpomkyLabs\PwaBundle\Dto\Workbox; diff --git a/src/Service/Plugin/BackgroundSyncPlugin.php b/src/WorkboxPlugin/BackgroundSyncPlugin.php similarity index 97% rename from src/Service/Plugin/BackgroundSyncPlugin.php rename to src/WorkboxPlugin/BackgroundSyncPlugin.php index 13b6aea..e8ee165 100644 --- a/src/Service/Plugin/BackgroundSyncPlugin.php +++ b/src/WorkboxPlugin/BackgroundSyncPlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; final readonly class BackgroundSyncPlugin extends CachePlugin { diff --git a/src/Service/Plugin/BroadcastUpdatePlugin.php b/src/WorkboxPlugin/BroadcastUpdatePlugin.php similarity index 93% rename from src/Service/Plugin/BroadcastUpdatePlugin.php rename to src/WorkboxPlugin/BroadcastUpdatePlugin.php index 67d0d8f..c8e527b 100644 --- a/src/Service/Plugin/BroadcastUpdatePlugin.php +++ b/src/WorkboxPlugin/BroadcastUpdatePlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; final readonly class BroadcastUpdatePlugin extends CachePlugin { diff --git a/src/Service/Plugin/CachePlugin.php b/src/WorkboxPlugin/CachePlugin.php similarity index 86% rename from src/Service/Plugin/CachePlugin.php rename to src/WorkboxPlugin/CachePlugin.php index f1c82a0..cba3e23 100644 --- a/src/Service/Plugin/CachePlugin.php +++ b/src/WorkboxPlugin/CachePlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; abstract readonly class CachePlugin { diff --git a/src/Service/Plugin/CacheableResponsePlugin.php b/src/WorkboxPlugin/CacheableResponsePlugin.php similarity index 94% rename from src/Service/Plugin/CacheableResponsePlugin.php rename to src/WorkboxPlugin/CacheableResponsePlugin.php index 978e102..d0b5096 100644 --- a/src/Service/Plugin/CacheableResponsePlugin.php +++ b/src/WorkboxPlugin/CacheableResponsePlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; final readonly class CacheableResponsePlugin extends CachePlugin { diff --git a/src/Service/Plugin/ExpirationPlugin.php b/src/WorkboxPlugin/ExpirationPlugin.php similarity index 91% rename from src/Service/Plugin/ExpirationPlugin.php rename to src/WorkboxPlugin/ExpirationPlugin.php index c87b3a6..d260098 100644 --- a/src/Service/Plugin/ExpirationPlugin.php +++ b/src/WorkboxPlugin/ExpirationPlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; final readonly class ExpirationPlugin extends CachePlugin { diff --git a/src/Service/Plugin/RangeRequestsPlugin.php b/src/WorkboxPlugin/RangeRequestsPlugin.php similarity index 87% rename from src/Service/Plugin/RangeRequestsPlugin.php rename to src/WorkboxPlugin/RangeRequestsPlugin.php index 6ad1242..42a0c40 100644 --- a/src/Service/Plugin/RangeRequestsPlugin.php +++ b/src/WorkboxPlugin/RangeRequestsPlugin.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SpomkyLabs\PwaBundle\Service\Plugin; +namespace SpomkyLabs\PwaBundle\WorkboxPlugin; final readonly class RangeRequestsPlugin extends CachePlugin { diff --git a/tests/config.php b/tests/config.php index 523c3e3..fc87896 100644 --- a/tests/config.php +++ b/tests/config.php @@ -226,7 +226,7 @@ 'scope' => '/', 'use_cache' => true, 'workbox' => [ - 'page_caches' => [ + 'resource_caches' => [ [ 'match_callback' => 'regex:.*', 'strategy' => 'StaleWhileRevalidate',