From 7f20a8f4a4931bf5f891303bb46547c609a70df0 Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:49:30 +0200 Subject: [PATCH 1/6] chore: Update composer dependencies and remove unused packages --- composer.json | 8 +--- config/wireuse.php | 33 ++++++++----- .../Discover/ComponentStructureScout.php | 6 +-- src/WireUseServiceProvider.php | 48 ++++++++++++++++--- 4 files changed, 68 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 357425f..6044762 100644 --- a/composer.json +++ b/composer.json @@ -23,12 +23,8 @@ "illuminate/view": "^10.0|^11.0", "laravel/scout": "^10.0|^11.0", "livewire/livewire": "^3.4", - "spatie/laravel-package-tools": "^1.16.3", - "spatie/php-structure-discoverer": "^2.1", - "spatie/laravel-html": "^3.11", - "spatie/laravel-model-states": "^2.7", - "artesaos/seotools": "^1.3", - "blade-ui-kit/blade-icons": "^1.6.0" + "spatie/laravel-package-tools": "^1.16.4", + "artesaos/seotools": "^1.3" }, "require-dev": { "larastan/larastan": "^2.9", diff --git a/config/wireuse.php b/config/wireuse.php index 74e8c89..b1bf958 100644 --- a/config/wireuse.php +++ b/config/wireuse.php @@ -1,14 +1,23 @@ [ + // \Foxws\WireUse\Support\Livewire\StateObjects\SupportStateObjects::class, + // \Foxws\WireUse\Support\Livewire\ModelStateObjects\SupportModelStateObjects::class, + ], + /* |-------------------------------------------------------------------------- | Laravel HTML @@ -16,16 +25,13 @@ | | This extends Laravel HTML. | + | @doc https://foxws.nl/posts/wireuse/laravel-html | @doc https://spatie.be/docs/laravel-html/v3 | */ 'html' => [ - 'mixins' => [ - Html::class => HtmlExtendedMixin::class, - BaseElement::class => BaseElementMixin::class, - Elements\A::class => LinkElementMixin::class, - ], + 'mixins' => false, ], /* @@ -35,11 +41,14 @@ | | This controls structure discovery. | + | @doc https://foxws.nl/posts/wireuse/structure-scout | @doc https://github.com/spatie/php-structure-discoverer | */ 'scout' => [ + 'enabled' => false, + 'cache_store' => null, 'cache_lifetime' => 60 * 60 * 24 * 7, diff --git a/src/Support/Discover/ComponentStructureScout.php b/src/Support/Discover/ComponentStructureScout.php index b451943..5252272 100644 --- a/src/Support/Discover/ComponentStructureScout.php +++ b/src/Support/Discover/ComponentStructureScout.php @@ -23,14 +23,14 @@ protected function definition(): Discover ->full(); } - public function prefix(string $prefix): static + public function prefix(?string $prefix = null): static { $this->prefix = trim($prefix, '-'); return $this; } - public function path(string $path): static + public function path(?string $path = null): static { $this->path = $path; @@ -39,7 +39,7 @@ public function path(string $path): static public function identifier(): string { - return $this->prefix ?? static::class; + return $this->prefix ?? class_basename(static::class); } public function cacheStore(): ?string diff --git a/src/WireUseServiceProvider.php b/src/WireUseServiceProvider.php index 3d5d27f..004df4a 100644 --- a/src/WireUseServiceProvider.php +++ b/src/WireUseServiceProvider.php @@ -2,8 +2,12 @@ namespace Foxws\WireUse; +use Composer\InstalledVersions; use Foxws\WireUse\Scout\ComponentScout; use Foxws\WireUse\Scout\LivewireScout; +use Foxws\WireUse\Support\Html\Mixins\BaseElementMixin; +use Foxws\WireUse\Support\Html\Mixins\HtmlExtendedMixin; +use Foxws\WireUse\Support\Html\Mixins\LinkElementMixin; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -18,8 +22,9 @@ public function configurePackage(Package $package): void public function packageRegistered(): void { - $this->app->singleton(ComponentScout::class, fn () => new ComponentScout); - $this->app->singleton(LivewireScout::class, fn () => new LivewireScout); + if (config('wireuse.scout.enabled', false)) { + $this->registerStructureDiscovery(); + } } public function packageBooted(): void @@ -31,9 +36,9 @@ public function packageBooted(): void protected function registerFeatures(): static { - foreach ([ - \Foxws\WireUse\Support\Livewire\StateObjects\SupportStateObjects::class, - ] as $feature) { + $features = config('wireuse.features', []); + + foreach ($features as $feature) { app('livewire')->componentHook($feature); } @@ -42,7 +47,38 @@ protected function registerFeatures(): static protected function registerMixins(): static { - foreach (config('wireuse.html.mixins', []) as $element => $mixin) { + if (config('wireuse.html.mixins', false)) { + $this->registerHtmlMixins(); + } + + return $this; + } + + protected function registerStructureDiscovery(): static + { + if (! InstalledVersions::isInstalled('spatie/php-structure-discoverer')) { + abort(500, 'The spatie/php-structure-discoverer package is required to use the Strucute Scout.'); + } + + $this->app->singleton(ComponentScout::class, fn () => new ComponentScout); + $this->app->singleton(LivewireScout::class, fn () => new LivewireScout); + + return $this; + } + + protected function registerHtmlMixins(): static + { + if (! InstalledVersions::isInstalled('spatie/laravel-html')) { + abort(500, 'The spatie/laravel-html package is required to use the HTML mixins.'); + } + + $mixins = [ + \Spatie\Html\Html::class => HtmlExtendedMixin::class, + \Spatie\Html\BaseElement::class => BaseElementMixin::class, + \Spatie\Html\Elements\A::class => LinkElementMixin::class, + ]; + + foreach ($mixins as $element => $mixin) { $element::mixin(new $mixin); } From c8325b3e2b3d894527f84672918f621ea744c33e Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:51:22 +0200 Subject: [PATCH 2/6] chore: Update composer dependencies and add new packages --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6044762..2aee197 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,10 @@ "phpstan/extension-installer": "^1.3.1", "phpstan/phpstan-deprecation-rules": "^1.1.4", "phpstan/phpstan-phpunit": "^1.3.16", - "spatie/laravel-ray": "^1.35.1" + "spatie/laravel-ray": "^1.35.1", + "spatie/laravel-html": "^3.11", + "spatie/laravel-model-states": "^2.7", + "blade-ui-kit/blade-icons": "^1.6.0" }, "autoload": { "psr-4": { From 0a1a3c9c63f89fe3bfb1aa87c3459b6cc4c5a4e3 Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:51:50 +0200 Subject: [PATCH 3/6] chore: Remove unused packages and update composer dependencies --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2aee197..d680287 100644 --- a/composer.json +++ b/composer.json @@ -39,8 +39,7 @@ "phpstan/phpstan-phpunit": "^1.3.16", "spatie/laravel-ray": "^1.35.1", "spatie/laravel-html": "^3.11", - "spatie/laravel-model-states": "^2.7", - "blade-ui-kit/blade-icons": "^1.6.0" + "spatie/laravel-model-states": "^2.7" }, "autoload": { "psr-4": { From ae72fc5acd8140ef02b386d465b2d70c34809275 Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:54:43 +0200 Subject: [PATCH 4/6] chore: Add spatie/php-structure-discoverer package to composer dependencies --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index d680287..4ecdf5f 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "phpstan/phpstan-deprecation-rules": "^1.1.4", "phpstan/phpstan-phpunit": "^1.3.16", "spatie/laravel-ray": "^1.35.1", + "spatie/php-structure-discoverer": "^2.1", "spatie/laravel-html": "^3.11", "spatie/laravel-model-states": "^2.7" }, From ae45da45b312ccadaa339421a7c0bfda5ada911f Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:56:52 +0200 Subject: [PATCH 5/6] fix spelling --- src/WireUseServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WireUseServiceProvider.php b/src/WireUseServiceProvider.php index 004df4a..4b587c5 100644 --- a/src/WireUseServiceProvider.php +++ b/src/WireUseServiceProvider.php @@ -57,7 +57,7 @@ protected function registerMixins(): static protected function registerStructureDiscovery(): static { if (! InstalledVersions::isInstalled('spatie/php-structure-discoverer')) { - abort(500, 'The spatie/php-structure-discoverer package is required to use the Strucute Scout.'); + abort(500, 'The spatie/php-structure-discoverer package is required to use the Structure Discovery.'); } $this->app->singleton(ComponentScout::class, fn () => new ComponentScout); From d53d16200a53b668c7a5e7a5670fcd575d2e0997 Mon Sep 17 00:00:00 2001 From: francoism90 Date: Tue, 6 Aug 2024 12:58:15 +0200 Subject: [PATCH 6/6] chore: Add blade-ui-kit/blade-icons package to composer dependencies --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ecdf5f..35ecf8b 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,8 @@ "spatie/laravel-ray": "^1.35.1", "spatie/php-structure-discoverer": "^2.1", "spatie/laravel-html": "^3.11", - "spatie/laravel-model-states": "^2.7" + "spatie/laravel-model-states": "^2.7", + "blade-ui-kit/blade-icons": "^1.6.0" }, "autoload": { "psr-4": {