Package com.vaadin.flow.internal
Class ActiveStyleSheetTracker
java.lang.Object
com.vaadin.flow.internal.ActiveStyleSheetTracker
- All Implemented Interfaces:
Serializable
Tracks the set of all active stylesheets used by the running application
during development time.
The tracker keeps a per-session set of stylesheet URLs that are currently
applied via @StyleSheet and a global set for AppShell stylesheets
that are applied to all pages.
Per-session tracking is used for component-based annotations and to avoid accidentally adding stylesheets to those UIs not using a given component, when a new stylesheet is added and hot-reloaded.
The data is stored in the VaadinContext and can be retrieved from any
module using get(VaadinService).
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ActiveStyleSheetTrackerget(VaadinContext context) Returns the tracker instance stored in the givenVaadinContext, creating it if necessary.static ActiveStyleSheetTrackerget(VaadinService service) Returns the tracker instance stored in the given service context, creating it if necessary.Returns all currently active stylesheet URLs, including AppShell URLs and components.voidRegister that the given stylesheet URL is active on the page and eligible for hot-reload.voidtrackForAppShell(Collection<String> urls) Replaces the set of active AppShell stylesheet URLs.voidRegister that the given stylesheet URL is no longer active on the page and should not be hot-reloaded.
-
Method Details
-
get
Returns the tracker instance stored in the given service context, creating it if necessary.- Parameters:
service- the activeVaadinService- Returns:
- the tracker instance, never null
-
get
Returns the tracker instance stored in the givenVaadinContext, creating it if necessary.- Parameters:
context- theVaadinContext- Returns:
- the tracker instance, never null
-
trackAddForComponent
Register that the given stylesheet URL is active on the page and eligible for hot-reload.- Parameters:
url- the stylesheet URL to be hot-reloaded
-
trackRemoveForComponent
Register that the given stylesheet URL is no longer active on the page and should not be hot-reloaded.- Parameters:
url- the stylesheet URL to be skipped during hot-reload
-
trackForAppShell
Replaces the set of active AppShell stylesheet URLs.- Parameters:
urls- the new set of app shell stylesheet URLs to be hot-reloaded
-
getActiveUrls
Returns all currently active stylesheet URLs, including AppShell URLs and components.- Returns:
- a new set containing all active stylesheet URLs to be hot-reloaded
-