Skip to content

Commit

Permalink
chore: Update composer dependencies and remove unused packages
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Aug 6, 2024
1 parent c341e87 commit 7f20a8f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 27 deletions.
8 changes: 2 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 21 additions & 12 deletions config/wireuse.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
<?php

use Foxws\WireUse\Support\Html\Mixins\BaseElementMixin;
use Foxws\WireUse\Support\Html\Mixins\HtmlExtendedMixin;
use Foxws\WireUse\Support\Html\Mixins\LinkElementMixin;
use Spatie\Html\BaseElement;
use Spatie\Html\Elements;
use Spatie\Html\Html;

return [

/*
|--------------------------------------------------------------------------
| Livewire Features
|--------------------------------------------------------------------------
|
| This controls Livewire component features.
|
| @doc https://foxws.nl/posts/wireuse/property-synthesizers
|
*/

'features' => [
// \Foxws\WireUse\Support\Livewire\StateObjects\SupportStateObjects::class,
// \Foxws\WireUse\Support\Livewire\ModelStateObjects\SupportModelStateObjects::class,
],

/*
|--------------------------------------------------------------------------
| Laravel HTML
|--------------------------------------------------------------------------
|
| 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,
],

/*
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Discover/ComponentStructureScout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
48 changes: 42 additions & 6 deletions src/WireUseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 7f20a8f

Please sign in to comment.