leonvogt / hotwire-dev-tools

Browser Dev Tools for Turbo and Stimulus
MIT License
184 stars 4 forks source link

Highlight non registered Stimulus controllers #5

Closed leonvogt closed 4 months ago

leonvogt commented 4 months ago

It would be handy to have a "connected indicator" in the Stimulus tab, which indicates if the Stimulus identifier was found on the window.Stimulus object.

List of all Stimulus controllers, in the current context:

window.Stimulus?.controllers.map(controller => controller.scope.identifier)

Since the content script doesn't have access to the same window object, we have to inject a custom JS file which will gather the currently registered controllers.

Also, although window.Stimulus is the default we probably need to let the user configure the mapped window application.

References:

leonvogt commented 4 months ago

The non registered Stimulus controllers are getting highlighted now, but we are only checking window.Stimulus.
In the future we should find a way to handle different Stimulus application names as well.