refactor: migrate legacy wire namespace to wrn
Quality / quality (ubuntu-latest) (push) Failing after 9m49s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 18:51:15 +05:30
parent ec23dd4c93
commit 2c960fc1dc
488 changed files with 27306 additions and 19063 deletions
+13 -13
View File
@@ -11,7 +11,7 @@
* `data-room-reset` clear after send). Optional `data-room-user` identifies
* the connection.
*
* 2. Programmatic: `const room = wire.room("chat"); room.on("chat", fn);
* 2. Programmatic: `const room = wrn.room("chat"); room.on("chat", fn);
* room.send({ type: "chat", text })`. Handles connect, JSON, reconnect.
*
* Rebinds on `wrnexus:navigated` (client-side nav) and closes rooms whose
@@ -21,8 +21,8 @@
export const REALTIME_RUNTIME = String.raw`
(function () {
if (!("WebSocket" in window)) return;
var wire = (window.wire = window.wire || {});
if (wire.room) return; // already installed
var wrn = (window.wrn = window.wrn || {});
if (wrn.room) return; // already installed
var open = {}; // normalized room+query key -> room connection
function normalizedQuery(query) {
@@ -107,7 +107,7 @@ export const REALTIME_RUNTIME = String.raw`
connect();
return api;
}
wire.room = openRoom;
wrn.room = openRoom;
// --- Declarative binding ---------------------------------------------------
@@ -139,11 +139,11 @@ export const REALTIME_RUNTIME = String.raw`
var user = el.getAttribute("data-room-user");
var query = el.getAttribute("data-room-query") || (user ? "user=" + encodeURIComponent(user) : "");
var key = roomKey(name, query);
if (el.__wireRoomBound && el.__wireRoomKey === key) return;
el.__wireRoomBound = true;
el.__wireRoomKey = key;
if (el.__wrnRoomBound && el.__wrnRoomKey === key) return;
el.__wrnRoomBound = true;
el.__wrnRoomKey = key;
var room = openRoom(name, query);
el.__wireRoom = room;
el.__wrnRoom = room;
var log = el.querySelector("[data-room-log]");
var status = el.querySelector("[data-room-status]");
@@ -176,8 +176,8 @@ export const REALTIME_RUNTIME = String.raw`
});
var form = el.querySelector("form[data-room-send]");
if (form && !form.__wireRoomForm) {
form.__wireRoomForm = true;
if (form && !form.__wrnRoomForm) {
form.__wrnRoomForm = true;
form.addEventListener("submit", function (e) {
e.preventDefault();
var data = {};
@@ -185,7 +185,7 @@ export const REALTIME_RUNTIME = String.raw`
var input = form.elements[i];
if (input.name) data[input.name] = input.value;
}
if (el.__wireRoom) el.__wireRoom.send(data);
if (el.__wrnRoom) el.__wrnRoom.send(data);
for (var j = 0; j < form.elements.length; j++) {
if (form.elements[j].hasAttribute("data-room-reset")) form.elements[j].value = "";
}
@@ -198,13 +198,13 @@ export const REALTIME_RUNTIME = String.raw`
var present = {};
for (var i = 0; i < containers.length; i++) {
bindContainer(containers[i]);
if (containers[i].__wireRoomKey) present[containers[i].__wireRoomKey] = true;
if (containers[i].__wrnRoomKey) present[containers[i].__wrnRoomKey] = true;
}
// Close rooms whose container has left the page (client-side navigation).
for (var nm in open) if (!present[nm]) open[nm].close();
}
wire.bindRooms = bindAll;
wrn.bindRooms = bindAll;
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", function () { bindAll(document); });
else bindAll(document);
window.addEventListener("wrnexus:navigated", function () { bindAll(document); });