v0.1.0-pre.061

This commit is contained in:
2026-07-28 18:41:30 +02:00
parent c7bad46f50
commit f40fb78817
527 changed files with 4598 additions and 4114 deletions

View File

@@ -1,5 +1,5 @@
// file: kb-app-demo-desktop/frontend/ts/demo_ws.ts
// version: 7
// version: 8
import * as bootstrap from "bootstrap";
import "simplebar";
@@ -7,6 +7,7 @@ import ResizeObserver from "resize-observer-polyfill";
import {invoke} from "@tauri-apps/api/core";
import {listen} from "@tauri-apps/api/event";
import {frontendDebug, frontendError, installFrontendConsoleBridge} from "./frontend_log.ts";
import {renderJsonViewer} from "./json_viewer.ts";
import type {DemoWsExecutionPayload} from "./bindings/kb_app_demo_desktop/demo_ws/DemoWsExecutionPayload.ts";
import type {DemoWsMessagePayload} from "./bindings/kb_app_demo_desktop/demo_ws/DemoWsMessagePayload.ts";
import type {DemoWsMethodOption} from "./bindings/kb_app_demo_desktop/demo_ws/DemoWsMethodOption.ts";
@@ -81,13 +82,6 @@ function clearWsMessages(): void {
writeWsMessages("");
}
function jsonText(value: unknown): string {
if (typeof value === "string") {
return value;
}
return JSON.stringify(value, null, 2);
}
function roleSupportsMethod(role: DemoWsRoleOption, method: DemoWsMethodOption): boolean {
return role.requestKinds.includes("*") || role.requestKinds.includes(method.requestKind);
}
@@ -176,7 +170,7 @@ function setConnectedUi(status: DemoWsStatusPayload): void {
disconnectButton.disabled = !status.connected;
}
refreshSubscriptionSelect(status);
writeTextarea("#wsStatusOutput", jsonText(status));
renderJsonViewer("#wsStatusOutput", status);
}
function formatWsExecutionPayload(payload: DemoWsExecutionPayload): string {
@@ -221,10 +215,10 @@ async function refreshWsOptions(): Promise<void> {
async function refreshWsPool(): Promise<void> {
try {
const snapshots = await invoke("demo_ws_list_pool_clients");
writeTextarea("#wsPoolOutput", jsonText(snapshots));
renderJsonViewer("#wsPoolOutput", snapshots);
} catch (caughtError) {
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
writeTextarea("#wsPoolOutput", `Erreur : ${message}`);
renderJsonViewer("#wsPoolOutput", {status: "error", message});
frontendError("kb-app-demo-desktop.frontend.demo_ws", `WebSocket pool refresh failed: ${message}`);
}
}
@@ -235,7 +229,7 @@ async function refreshWsStatus(): Promise<void> {
setConnectedUi(status);
} catch (caughtError) {
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
writeTextarea("#wsStatusOutput", `Erreur statut WebSocket : ${message}`);
renderJsonViewer("#wsStatusOutput", {status: "error", message});
frontendError("kb-app-demo-desktop.frontend.demo_ws", `WebSocket status failed: ${message}`);
}
}
@@ -330,9 +324,6 @@ document.addEventListener("DOMContentLoaded", () => {
document.querySelector<HTMLButtonElement>("#refreshWsPoolButton")?.addEventListener("click", () => {
void refreshWsPool();
});
document.querySelector<HTMLButtonElement>("#copyWsPoolButton")?.addEventListener("click", () => {
void copyTextarea("#wsPoolOutput");
});
document.querySelector<HTMLButtonElement>("#copyWsResultButton")?.addEventListener("click", () => {
void copyTextarea("#wsResultOutput");
});