-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/profiler' into next
- Loading branch information
Showing
16 changed files
with
765 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Pentatrion\ViteBundle\Controller; | ||
|
||
use Pentatrion\ViteBundle\Service\Debug; | ||
use Pentatrion\ViteBundle\Twig\TypeExtension; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Twig\Environment; | ||
|
||
class ProfilerController | ||
{ | ||
public function __construct( | ||
private Debug $debug, | ||
private Environment $twig | ||
) { | ||
} | ||
|
||
public function info(): Response | ||
{ | ||
$viteConfigs = $this->debug->getViteCompleteConfigs(); | ||
|
||
$this->twig->addExtension(new TypeExtension()); | ||
|
||
$response = new Response( | ||
$this->twig->render('@PentatrionVite/Profiler/info.html.twig', [ | ||
'viteConfigs' => $viteConfigs, | ||
]) | ||
); | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Pentatrion\ViteBundle\DataCollector; | ||
|
||
use Pentatrion\ViteBundle\Model\Tag; | ||
use Pentatrion\ViteBundle\Service\EntrypointRenderer; | ||
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ViteCollector extends AbstractDataCollector | ||
{ | ||
public function __construct( | ||
private EntrypointRenderer $entrypointRenderer | ||
) { | ||
} | ||
|
||
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void | ||
{ | ||
$this->data = $this->entrypointRenderer->getRenderedFiles(); | ||
} | ||
|
||
/** | ||
* @return array<string, Tag> | ||
*/ | ||
public function getRenderedStyles(): array | ||
{ | ||
return $this->data['styles']; | ||
} | ||
|
||
/** | ||
* @return array<string, Tag> | ||
*/ | ||
public function getRenderedScripts(): array | ||
{ | ||
return $this->data['scripts']; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'pentatrion_vite.vite_collector'; | ||
} | ||
|
||
public static function getTemplate(): ?string | ||
{ | ||
return '@PentatrionVite/Collector/vite_collector.html.twig'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{% extends "@WebProfiler/Profiler/layout.html.twig" %} | ||
|
||
{% block toolbar %} | ||
{% set icon %} | ||
{{ include('@PentatrionVite/Collector/icon.svg') }} | ||
<span class="sf-toolbar-value">Vite</span> | ||
{% endset %} | ||
{% set text %} | ||
<div class="sf-toolbar-info-piece"> | ||
<b>Vite dev Server</b> | ||
<span> | ||
<a href="{{ path('_profiler_vite') }}">Config</a> | ||
</span> | ||
</div> | ||
<div class="sf-toolbar-info-piece"> | ||
<b>Rendered <script /></b> | ||
<span class="sf-toolbar-status">{{ collector.renderedScripts | length }}</span> | ||
</div> | ||
<div class="sf-toolbar-info-piece"> | ||
<b>Rendered <link /></b> | ||
<span class="sf-toolbar-status">{{ collector.renderedStyles | length }}</span> | ||
</div> | ||
{% endset %} | ||
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': true }) }} | ||
{% endblock %} | ||
|
||
{% block menu %} | ||
<span class="label"> | ||
<span class="icon"> | ||
{{ include('@PentatrionVite/Collector/icon.svg') }} | ||
</span> | ||
<strong>Vite</strong> | ||
</span> | ||
{% endblock %} | ||
|
||
{% block panel %} | ||
<h2>Rendered <script /></h2> | ||
{% for _, tag in collector.renderedScripts %} | ||
<table> | ||
<thead> | ||
<tr> | ||
<th class="key">Attribute</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for key, value in tag.attributes %} | ||
<tr> | ||
<th>{{ key }}</th> | ||
<td> | ||
<pre class="sf-dump">{{ value }}</pre> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endfor %} | ||
|
||
<h2>Rendered <link /></h2> | ||
{% for _, tag in collector.renderedStyles %} | ||
<table> | ||
<thead> | ||
<tr> | ||
<th class="key">Attribute</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for key, value in tag.attributes %} | ||
<tr> | ||
<th>{{ key }}</th> | ||
<td> | ||
<pre class="sf-dump">{{ value }}</pre> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endfor %} | ||
{% endblock %} |
Oops, something went wrong.