Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
46178ab
--wip-- [skip ci]
manuelleduc Oct 29, 2025
2342833
--wip-- [skip ci]
manuelleduc Oct 31, 2025
9329f6f
--wip-- [skip ci]
manuelleduc Oct 31, 2025
bc69034
--wip-- [skip ci]
manuelleduc Nov 3, 2025
8c26c55
XWIKI-23609: Easier importmap declaration for webjars
manuelleduc Nov 4, 2025
b9d41e8
--wip-- [skip ci]
manuelleduc Nov 10, 2025
7df2a5d
--wip-- [skip ci]
manuelleduc Nov 10, 2025
20bd2a0
--wip-- [skip ci]
manuelleduc Nov 10, 2025
fb58f1c
Merge remote-tracking branch 'origin/master' into XCOMMONS-3470
manuelleduc Nov 13, 2025
2de8ee0
--wip-- [skip ci]
manuelleduc Nov 13, 2025
ec5901d
Merge remote-tracking branch 'origin/master' into XCOMMONS-3470
manuelleduc Nov 13, 2025
2f0e5c4
--wip-- [skip ci]
manuelleduc Nov 13, 2025
ad37d22
--wip-- [skip ci]
manuelleduc Nov 13, 2025
44cb9e9
--wip-- [skip ci]
manuelleduc Nov 13, 2025
41433cd
--wip-- [skip ci]
manuelleduc Nov 13, 2025
1248cbd
--wip-- [skip ci]
manuelleduc Nov 13, 2025
63ea231
--wip-- [skip ci]
manuelleduc Nov 13, 2025
84c5fb6
--wip-- [skip ci]
manuelleduc Nov 13, 2025
8296b5f
Merge remote-tracking branch 'origin/master' into XCOMMONS-3470
manuelleduc Nov 14, 2025
669219c
--wip-- [skip ci]
manuelleduc Nov 14, 2025
2677bf8
Merge remote-tracking branch 'origin/master' into XCOMMONS-3470
manuelleduc Nov 14, 2025
d69aa54
add path validity check
manuelleduc Nov 14, 2025
d4db531
allow check path validity in the current module
manuelleduc Nov 14, 2025
094e3a0
Merge remote-tracking branch 'origin/master' into XCOMMONS-3470
manuelleduc Nov 21, 2025
a2d7f9d
--wip-- [skip ci]
manuelleduc Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions xwiki-platform-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
org.xwiki.contrib:authservice-backport-api,
org.xwiki.contrib:authservice-backport-default
</xwiki.platform.oldcore.extension.features>
<xwiki.enforcer.valid-importmap.skip>${xwiki.enforcer.skip}</xwiki.enforcer.valid-importmap.skip>
</properties>
<build>
<pluginManagement>
Expand Down Expand Up @@ -187,6 +188,36 @@
</analysisConfiguration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tool-enforcer-importmap</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<!-- Make sure declared importmap are valid. -->
<execution>
<id>enforce-valid-javascript-importmap</id>
<!-- Make sure the enforcer is performed after the artifacts for the current project are produced to be
able to check for the validity of path the the module itself.
-->
<phase>verify</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${xwiki.enforcer.valid-importmap.skip}</skip>
<rules>
<javascriptImportMapCheck/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
Expand Down Expand Up @@ -229,6 +260,7 @@
<module>xwiki-platform-index</module>
<module>xwiki-platform-instance</module>
<module>xwiki-platform-invitation</module>
<module>xwiki-platform-javascript</module>
<module>xwiki-platform-job</module>
<module>xwiki-platform-jodatime</module>
<module>xwiki-platform-lesscss</module>
Expand Down
35 changes: 35 additions & 0 deletions xwiki-platform-core/xwiki-platform-javascript/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-core</artifactId>
<version>18.0.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-javascript</artifactId>
<name>XWiki Platform - Javascript</name>
<packaging>pom</packaging>
<description>Modules related to the integration of Javascript concepts.</description>
<modules>
<module>xwiki-platform-javascript-importmap</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-javascript</artifactId>
<version>18.0.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-javascript-importmap</artifactId>
<name>XWiki Platform - Javascript - Importmap</name>
<packaging>jar</packaging>
<description>Scan extensions for importmap definition and inject them in the page html header.</description>
<properties>
<xwiki.jacoco.instructionRatio>0.42</xwiki.jacoco.instructionRatio>
</properties>
<dependencies>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-component-api</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-uiextension-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-extension-api</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-webjars-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-tool-test-component</artifactId>
<version>${commons.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-javascript</artifactId>
<version>${commons.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.javascript.importmap.internal;

import java.util.List;
import java.util.Objects;

import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.extension.event.AbstractExtensionEvent;
import org.xwiki.extension.event.ExtensionInstalledEvent;
import org.xwiki.extension.event.ExtensionUninstalledEvent;
import org.xwiki.extension.event.ExtensionUpgradedEvent;
import org.xwiki.model.namespace.WikiNamespace;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.event.Event;
import org.xwiki.wiki.descriptor.WikiDescriptorManager;

/**
* Listen for extensions related events (installed, uninstalled, upgraded) and clear {@link JavascriptImportmapResolver}
* cache when the events are received.
*
* @version $Id$
* @since 18.0.0RC1
*/
@Component
@Named(JavascriptImportmapEventListener.HINT)
@Singleton
public class JavascriptImportmapEventListener implements EventListener
{
/**
* Component hint.
*/
public static final String HINT = "JavascriptImportmapEventListener";

@Inject
private JavascriptImportmapResolver javascriptImportmapResolver;

@Inject
private WikiDescriptorManager wikiDescriptorManager;

@Override
public String getName()
{
return HINT;
}

@Override
public List<Event> getEvents()
{
return List.of(new ExtensionInstalledEvent(), new ExtensionUninstalledEvent(), new ExtensionUpgradedEvent());
}

@Override
public void onEvent(Event event, Object source, Object data)
{
if (event instanceof AbstractExtensionEvent extensionInstalledEvent) {
if (!extensionInstalledEvent.hasNamespace() || Objects.equals(extensionInstalledEvent.getNamespace(),
new WikiNamespace(this.wikiDescriptorManager.getCurrentWikiId()).serialize()))
{
// Only clear the cache for events related to the current wiki (i.e., local to the wiki or global to
// the whole farm).
this.javascriptImportmapResolver.clearCache();
}
}
}
}
Loading
Loading