From 0edd02dbec0f0ec2959232863cd05e51d7eb847a Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Sun, 22 Dec 2024 11:32:04 +0100 Subject: [PATCH] chore: bump Vaadin to 24.5 --- pom.xml | 6 ++-- vertx-vaadin-flow/pom.xml | 2 +- .../vaadin/VertxVaadinBrowserLiveReload.java | 7 ++++ .../VertxDebugWindowConnection.java | 34 ++++++++++++++----- .../communication/VertxVaadinLiveReload.java | 12 +++++++ .../vertx/vaadin/quarkus/it/ServiceIT.java | 2 +- vertx-vaadin-quarkus-extension/pom.xml | 4 +-- 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index ce469577..36646272 100644 --- a/pom.xml +++ b/pom.xml @@ -109,9 +109,9 @@ 2.41.1 4.5.9 - 24.4.10 - 24.4.6 - 24.4.6 + 24.5.9 + 24.5.10 + 24.5.9 6.0.0 1.14.11 diff --git a/vertx-vaadin-flow/pom.xml b/vertx-vaadin-flow/pom.xml index 07739ca1..02bc8f56 100644 --- a/vertx-vaadin-flow/pom.xml +++ b/vertx-vaadin-flow/pom.xml @@ -19,7 +19,7 @@ false 4.8.157 ${project.version} - 2.14.2 + 2.17.2 1.3.2 2.1.1 3.0.2 diff --git a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/VertxVaadinBrowserLiveReload.java b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/VertxVaadinBrowserLiveReload.java index 56a104c1..960155b6 100644 --- a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/VertxVaadinBrowserLiveReload.java +++ b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/VertxVaadinBrowserLiveReload.java @@ -32,6 +32,8 @@ import com.github.mcollovati.vertx.vaadin.communication.VertxDebugWindowConnection; import com.github.mcollovati.vertx.vaadin.sockjs.communication.VertxVaadinLiveReload; +import elemental.json.JsonObject; + class VertxVaadinBrowserLiveReload implements BrowserLiveReload { private final BrowserLiveReload delegate; @@ -77,6 +79,11 @@ public void update(String path, String content) { reloader.update(path, content); } + @Override + public void sendHmrEvent(String event, JsonObject eventData) { + reloader.sendHmrEvent(event, eventData); + } + @Override public void reload() { reloader.reload(); diff --git a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/communication/VertxDebugWindowConnection.java b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/communication/VertxDebugWindowConnection.java index 5b3272f4..3b57c29e 100644 --- a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/communication/VertxDebugWindowConnection.java +++ b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/communication/VertxDebugWindowConnection.java @@ -47,7 +47,6 @@ import com.vaadin.base.devserver.stats.DevModeUsageStatistics; import com.vaadin.experimental.FeatureFlags; import com.vaadin.flow.server.VaadinContext; -import com.vaadin.flow.server.startup.ApplicationConfiguration; import com.vaadin.pro.licensechecker.BuildType; import com.vaadin.pro.licensechecker.LicenseChecker; import com.vaadin.pro.licensechecker.Product; @@ -152,10 +151,25 @@ public void onMessage(String websocketId, String message) { } } - private void send(String websocketId, String command, Object data) { + public void sendHmrEvent(String event, JsonObject eventData) { + JsonObject msg = elemental.json.Json.createObject(); + msg.put("command", "hmr"); + JsonObject data = elemental.json.Json.createObject(); + msg.put("data", data); + data.put("event", event); + data.put("eventData", eventData); + broadcast(msg); + } + + private void send(String websocketId, String command, + Object data) { + send(websocketId, Json.encode(new DebugWindowMessage(command, data))); + } + + private void send(String websocketId, String json) { try { Optional.ofNullable(liveReload.get(websocketId)) - .ifPresent(producer -> producer.accept(Json.encode(new DebugWindowMessage(command, data)))); + .ifPresent(producer -> producer.accept(json)); } catch (Exception e) { getLogger().error("Error sending message", e); } @@ -163,7 +177,6 @@ private void send(String websocketId, String command, Object data) { public void onClose(String websocketId) { logger.debug("Live reload connection disconnected for {}", websocketId); - // Optional.ofNullable(liveReload.get(websocketId)).ifPresent(MessageProducer::close); for (DevToolsMessageHandler plugin : plugins) { plugin.handleDisconnect(getDevToolsInterface(websocketId)); } @@ -175,16 +188,16 @@ public void update(String path, String content) { msg.put("command", "update"); msg.put("path", path); msg.put("content", content); - sendToAll(msg); + broadcast(msg); } public void reload() { JsonObject msg = elemental.json.Json.createObject(); msg.put("command", "reload"); - sendToAll(msg); + broadcast(msg); } - private void sendToAll(JsonObject message) { + private void broadcast(JsonObject message) { String json = message.toJson(); liveReload.values().stream().filter(Objects::nonNull).forEach(socket -> socket.accept(json)); } @@ -223,7 +236,12 @@ public DevToolsInterfaceImpl(VertxDebugWindowConnection connection, String webso @Override public void send(String command, JsonObject data) { - connection.send(websocketId, command, data); + JsonObject msg = elemental.json.Json.createObject(); + msg.put("command", command); + if (data != null) { + msg.put("data", data); + } + connection.send(websocketId, msg.toJson()); } @Override diff --git a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/sockjs/communication/VertxVaadinLiveReload.java b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/sockjs/communication/VertxVaadinLiveReload.java index e72ccfee..62fa46d2 100644 --- a/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/sockjs/communication/VertxVaadinLiveReload.java +++ b/vertx-vaadin-flow/src/main/java/com/github/mcollovati/vertx/vaadin/sockjs/communication/VertxVaadinLiveReload.java @@ -22,6 +22,8 @@ */ package com.github.mcollovati.vertx.vaadin.sockjs.communication; +import elemental.json.JsonObject; + /** * Provides a way to reload browser tabs via web socket connection. */ @@ -42,4 +44,14 @@ public interface VertxVaadinLiveReload { */ void update(String path, String content); + /** + * Send a client side HMR event. + * + * @param event + * the event name + * @param eventData + * the event data + */ + void sendHmrEvent(String event, JsonObject eventData); + } diff --git a/vertx-vaadin-quarkus-extension/integration-tests/common-test-code/src/test/java/com/github/mcollovati/vertx/vaadin/quarkus/it/ServiceIT.java b/vertx-vaadin-quarkus-extension/integration-tests/common-test-code/src/test/java/com/github/mcollovati/vertx/vaadin/quarkus/it/ServiceIT.java index 044b2ae8..5fc8ea93 100644 --- a/vertx-vaadin-quarkus-extension/integration-tests/common-test-code/src/test/java/com/github/mcollovati/vertx/vaadin/quarkus/it/ServiceIT.java +++ b/vertx-vaadin-quarkus-extension/integration-tests/common-test-code/src/test/java/com/github/mcollovati/vertx/vaadin/quarkus/it/ServiceIT.java @@ -120,7 +120,7 @@ public void uiInitEventObserved() throws IOException { } private void assertSystemMessageEquals(String expected) { - WebElement message = findElement(By.cssSelector("div.v-system-error div.message")); + WebElement message = waitUntil(d -> findElement(By.cssSelector("div.v-system-error div.message"))); Assertions.assertEquals(expected, message.getText()); } } diff --git a/vertx-vaadin-quarkus-extension/pom.xml b/vertx-vaadin-quarkus-extension/pom.xml index 711b4d77..06ebecc2 100644 --- a/vertx-vaadin-quarkus-extension/pom.xml +++ b/vertx-vaadin-quarkus-extension/pom.xml @@ -21,10 +21,10 @@ 3.8.1 false - 11 + 17 UTF-8 UTF-8 - 3.8.6 + 3.12.2 3.1.2 ${surefire-plugin.version}