Skip to content

Commit

Permalink
Fix BackgroundSync and remove SW command
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Mar 7, 2024
1 parent 6556b2a commit f33866b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 93 deletions.
24 changes: 16 additions & 8 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,6 @@ parameters:
count: 1
path: src/Normalizer/UrlNormalizer.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
path: src/Resources/config/definition/asset_public_prefix.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -675,6 +670,14 @@ parameters:
count: 1
path: src/Resources/config/definition/web_client.php

-
message: """
#^Fetching class constant class of deprecated class SpomkyLabs\\\\PwaBundle\\\\Command\\\\CreateServiceWorkerCommand\\:
This command will be removed in the next major version\\. Create an empty file in assets/sw\\.js instead\\.$#
"""
count: 1
path: src/Resources/config/services.php

-
message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Service\\\\ServiceWorkerCompiler\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -686,11 +689,16 @@ parameters:
path: src/Service/ServiceWorkerCompiler.php

-
message: "#^Cannot access offset 'public_prefix' on mixed\\.$#"
message: "#^Method SpomkyLabs\\\\PwaBundle\\\\SpomkyLabsPwaBundle\\:\\:loadExtension\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
count: 1
path: src/SpomkyLabsPwaBundle.php

-
message: "#^Method SpomkyLabs\\\\PwaBundle\\\\SpomkyLabsPwaBundle\\:\\:loadExtension\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\ManifestCompileEventListener\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Subscriber/ManifestCompileEventListener.php

-
message: "#^Property SpomkyLabs\\\\PwaBundle\\\\Subscriber\\\\PwaDevServerSubscriber\\:\\:\\$jsonOptions type has no value type specified in iterable type array\\.$#"
count: 1
path: src/SpomkyLabsPwaBundle.php
path: src/Subscriber/PwaDevServerSubscriber.php
82 changes: 0 additions & 82 deletions src/Command/CreateServiceWorkerCommand.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Facebook\WebDriver\WebDriverDimension;
use SpomkyLabs\PwaBundle\Command\CreateIconsCommand;
use SpomkyLabs\PwaBundle\Command\CreateScreenshotCommand;
use SpomkyLabs\PwaBundle\Command\CreateServiceWorkerCommand;
use SpomkyLabs\PwaBundle\Dto\Manifest;
use SpomkyLabs\PwaBundle\Dto\ServiceWorker;
use SpomkyLabs\PwaBundle\ImageProcessor\GDImageProcessor;
Expand Down Expand Up @@ -56,7 +55,6 @@
;

/*** Commands ***/
$container->set(CreateServiceWorkerCommand::class);
if (class_exists(Client::class) && class_exists(WebDriverDimension::class) && class_exists(MimeTypes::class)) {
$container->set(CreateScreenshotCommand::class);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Service/ServiceWorkerCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
private array $jsonOptions;

private string $manifestPublicUrl;

private string $assetPublicPrefix;

public function __construct(
Expand Down Expand Up @@ -339,7 +340,7 @@ private function processBackgroundSyncRule(Workbox $workbox, string $body): stri
$options = count($options) === 0 ? '' : $this->serializer->serialize($options, 'json', $this->jsonOptions);
$declaration .= <<<BACKGROUND_SYNC_RULE_STRATEGY
workbox.routing.registerRoute(
'{$sync->regex}',
new RegExp('{$sync->regex}'),
new workbox.strategies.NetworkOnly({plugins: [new workbox.backgroundSync.BackgroundSyncPlugin('{$sync->queueName}',{$options})] }),
'{$sync->method}'
);
Expand Down
1 change: 1 addition & 0 deletions src/Subscriber/ManifestCompileEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
final readonly class ManifestCompileEventListener
{
private string $manifestPublicUrl;

private array $jsonOptions;

public function __construct(
Expand Down
1 change: 1 addition & 0 deletions src/Subscriber/PwaDevServerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
private null|string $workboxPublicUrl;

private null|string $workboxVersion;

private array $jsonOptions;

public function __construct(
Expand Down

0 comments on commit f33866b

Please sign in to comment.