Search in sources :

Example 1 with CssImport

use of com.vaadin.flow.component.dependency.CssImport in project flow by vaadin.

the class UIInternals method addFallbackDependencies.

private void addFallbackDependencies(DependencyInfo dependency) {
    if (isFallbackChunkLoaded) {
        return;
    }
    VaadinContext context = ui.getSession().getService().getContext();
    FallbackChunk chunk = context.getAttribute(FallbackChunk.class);
    if (chunk == null) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Fallback chunk is not available, skipping fallback dependencies load");
        }
        return;
    }
    Set<String> modules = chunk.getModules();
    Set<CssImportData> cssImportsData = chunk.getCssImports();
    if (modules.isEmpty() && cssImportsData.isEmpty()) {
        getLogger().debug("Fallback chunk is empty, skipping fallback dependencies load");
        return;
    }
    List<CssImport> cssImports = dependency.getCssImports();
    List<JavaScript> javaScripts = dependency.getJavaScripts();
    List<JsModule> jsModules = dependency.getJsModules();
    if (jsModules.stream().map(JsModule::value).anyMatch(modules::contains)) {
        loadFallbackChunk();
        return;
    }
    if (javaScripts.stream().map(JavaScript::value).anyMatch(modules::contains)) {
        loadFallbackChunk();
        return;
    }
    if (cssImports.stream().map(this::buildData).anyMatch(cssImportsData::contains)) {
        loadFallbackChunk();
        return;
    }
}
Also used : JsModule(com.vaadin.flow.component.dependency.JsModule) CssImport(com.vaadin.flow.component.dependency.CssImport) VaadinContext(com.vaadin.flow.server.VaadinContext) FallbackChunk(com.vaadin.flow.server.frontend.FallbackChunk) JavaScript(com.vaadin.flow.component.dependency.JavaScript) CssImportData(com.vaadin.flow.server.frontend.FallbackChunk.CssImportData)

Aggregations

CssImport (com.vaadin.flow.component.dependency.CssImport)1 JavaScript (com.vaadin.flow.component.dependency.JavaScript)1 JsModule (com.vaadin.flow.component.dependency.JsModule)1 VaadinContext (com.vaadin.flow.server.VaadinContext)1 FallbackChunk (com.vaadin.flow.server.frontend.FallbackChunk)1 CssImportData (com.vaadin.flow.server.frontend.FallbackChunk.CssImportData)1