2
2
3
3
namespace Foxws \WireUse ;
4
4
5
+ use Composer \InstalledVersions ;
5
6
use Foxws \WireUse \Scout \ComponentScout ;
6
7
use Foxws \WireUse \Scout \LivewireScout ;
8
+ use Foxws \WireUse \Support \Html \Mixins \BaseElementMixin ;
9
+ use Foxws \WireUse \Support \Html \Mixins \HtmlExtendedMixin ;
10
+ use Foxws \WireUse \Support \Html \Mixins \LinkElementMixin ;
7
11
use Spatie \LaravelPackageTools \Package ;
8
12
use Spatie \LaravelPackageTools \PackageServiceProvider ;
9
13
@@ -18,8 +22,9 @@ public function configurePackage(Package $package): void
18
22
19
23
public function packageRegistered (): void
20
24
{
21
- $ this ->app ->singleton (ComponentScout::class, fn () => new ComponentScout );
22
- $ this ->app ->singleton (LivewireScout::class, fn () => new LivewireScout );
25
+ if (config ('wireuse.scout.enabled ' , false )) {
26
+ $ this ->registerStructureDiscovery ();
27
+ }
23
28
}
24
29
25
30
public function packageBooted (): void
@@ -31,9 +36,9 @@ public function packageBooted(): void
31
36
32
37
protected function registerFeatures (): static
33
38
{
34
- foreach ([
35
- \ Foxws \ WireUse \ Support \ Livewire \ StateObjects \SupportStateObjects::class,
36
- ] as $ feature ) {
39
+ $ features = config ( ' wireuse.features ' , []);
40
+
41
+ foreach ( $ features as $ feature ) {
37
42
app ('livewire ' )->componentHook ($ feature );
38
43
}
39
44
@@ -42,7 +47,38 @@ protected function registerFeatures(): static
42
47
43
48
protected function registerMixins (): static
44
49
{
45
- foreach (config ('wireuse.html.mixins ' , []) as $ element => $ mixin ) {
50
+ if (config ('wireuse.html.mixins ' , false )) {
51
+ $ this ->registerHtmlMixins ();
52
+ }
53
+
54
+ return $ this ;
55
+ }
56
+
57
+ protected function registerStructureDiscovery (): static
58
+ {
59
+ if (! InstalledVersions::isInstalled ('spatie/php-structure-discoverer ' )) {
60
+ abort (500 , 'The spatie/php-structure-discoverer package is required to use the Structure Discovery. ' );
61
+ }
62
+
63
+ $ this ->app ->singleton (ComponentScout::class, fn () => new ComponentScout );
64
+ $ this ->app ->singleton (LivewireScout::class, fn () => new LivewireScout );
65
+
66
+ return $ this ;
67
+ }
68
+
69
+ protected function registerHtmlMixins (): static
70
+ {
71
+ if (! InstalledVersions::isInstalled ('spatie/laravel-html ' )) {
72
+ abort (500 , 'The spatie/laravel-html package is required to use the HTML mixins. ' );
73
+ }
74
+
75
+ $ mixins = [
76
+ \Spatie \Html \Html::class => HtmlExtendedMixin::class,
77
+ \Spatie \Html \BaseElement::class => BaseElementMixin::class,
78
+ \Spatie \Html \Elements \A::class => LinkElementMixin::class,
79
+ ];
80
+
81
+ foreach ($ mixins as $ element => $ mixin ) {
46
82
$ element ::mixin (new $ mixin );
47
83
}
48
84
0 commit comments