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
+1 -1
View File
@@ -4,7 +4,7 @@ export const ACTION_RUNTIME = String.raw`
window.__wrnexusActionsInstalled = true;
function csrf() {
var match = document.cookie.match(/(?:^|;\s*)wire-csrf=([^;]+)/);
var match = document.cookie.match(/(?:^|;\s*)wrn-csrf=([^;]+)/);
return match ? decodeURIComponent(match[1]) : "";
}
+6 -6
View File
@@ -437,11 +437,11 @@ export const NAV_RUNTIME = String.raw`
try {
if (
window.__wireValidate &&
typeof window.__wireValidate.init ===
window.__wrnValidate &&
typeof window.__wrnValidate.init ===
"function"
) {
window.__wireValidate.init(document);
window.__wrnValidate.init(document);
}
} catch (error) {
console.error(
@@ -452,11 +452,11 @@ export const NAV_RUNTIME = String.raw`
try {
if (
window.wireTheme &&
typeof window.wireTheme.bind ===
window.wrnTheme &&
typeof window.wrnTheme.bind ===
"function"
) {
window.wireTheme.bind(document);
window.wrnTheme.bind(document);
}
} catch (error) {
console.error(
+41 -41
View File
@@ -147,10 +147,10 @@ export const REACTIVE_RUNTIME = String.raw`
* identical call in an inline handler works, which is a maddening
* inconsistency.
*
* wireToast is the stable name. toast is the ergonomic alias and defers to
* wrnToast is the stable name. toast is the ergonomic alias and defers to
* an application that already defines one.
*/
window.wireToast = toastApi;
window.wrnToast = toastApi;
if (!window.toast) window.toast = toastApi;
// Read straight off window, no binding needed (objects, not functions).
@@ -229,11 +229,11 @@ export const REACTIVE_RUNTIME = String.raw`
Array.prototype.forEach.call(rules || [], function (rule) {
var cssText = rule.cssText || "";
var match;
var pattern = /var\(\s*(--wire-[A-Za-z0-9_-]+)/g;
var pattern = /var\(\s*(--wrn-[A-Za-z0-9_-]+)/g;
while ((match = pattern.exec(cssText))) referenced[match[1]] = true;
if (rule.style) {
Array.prototype.forEach.call(rule.style, function (property) {
if (String(property).indexOf("--wire-") === 0) declared[property] = true;
if (String(property).indexOf("--wrn-") === 0) declared[property] = true;
});
}
try {
@@ -248,7 +248,7 @@ export const REACTIVE_RUNTIME = String.raw`
});
Array.prototype.forEach.call(document.querySelectorAll("[style]") || [], function (element) {
Array.prototype.forEach.call(element.style || [], function (property) {
if (String(property).indexOf("--wire-") === 0) declared[property] = true;
if (String(property).indexOf("--wrn-") === 0) declared[property] = true;
});
});
var rendered = window.getComputedStyle(document.documentElement);
@@ -2225,7 +2225,7 @@ export const REACTIVE_RUNTIME = String.raw`
Array.prototype.slice
.call(el.querySelectorAll("[data-for]"))
.forEach(function (tpl) {
// Only top-level templates here; nested ones are wired by the item
// Only top-level templates here; nested ones are connected by the item
// that contains them, once it has values to give them.
if (tpl.parentNode && tpl.parentNode.closest && tpl.parentNode.closest("[data-for]")) {
return;
@@ -2289,7 +2289,7 @@ export const REACTIVE_RUNTIME = String.raw`
// data-show="expr" — toggle visibility on truthiness. This directive is
// intentionally non-destructive because popovers, selects and remote data
// controls keep event wiring and state while closed. Use a compiled {#if}
// controls keep event integration and state while closed. Use a compiled {#if}
// block when the inactive branch must not be rendered.
el.querySelectorAll("[data-show]").forEach(function (node) {
if (!owns(node)) return;
@@ -3367,9 +3367,9 @@ export const REACTIVE_RUNTIME = String.raw`
nav.dispatchEvent(new CustomEvent("change", { detail: { href: href, label: label } }));
}
function wireScrollspy(nav) {
if (nav.__wrnScrollspyWired) return;
nav.__wrnScrollspyWired = true;
function bindScrollspy(nav) {
if (nav.__wrnScrollspyBound) return;
nav.__wrnScrollspyBound = true;
nav.addEventListener("click", function (event) {
var t = event.target;
@@ -3412,13 +3412,13 @@ export const REACTIVE_RUNTIME = String.raw`
function setupScrollspy() {
if (window.__wrnexusScrollspyBound) return;
window.__wrnexusScrollspyBound = true;
var wireAll = function () {
var bindAll = function () {
var navs = document.querySelectorAll("[data-wrn-scrollspy]");
for (var index = 0; index < navs.length; index += 1) wireScrollspy(navs[index]);
for (var index = 0; index < navs.length; index += 1) bindScrollspy(navs[index]);
};
wireAll();
bindAll();
watchDocument(function () {
window.setTimeout(wireAll, 0);
window.setTimeout(bindAll, 0);
});
}
@@ -3605,7 +3605,7 @@ export const REACTIVE_RUNTIME = String.raw`
switcher.addEventListener("toggle", function (event) {
var opened = event.target;
if (!opened || opened.tagName !== "DETAILS" || !opened.open) return;
switcher.querySelectorAll(".wire-preferences__menu[open]").forEach(function (menu) {
switcher.querySelectorAll(".wrn-preferences__menu[open]").forEach(function (menu) {
if (menu !== opened) menu.removeAttribute("open");
});
}, true);
@@ -3615,14 +3615,14 @@ export const REACTIVE_RUNTIME = String.raw`
document.addEventListener("pointerdown", function (event) {
document.querySelectorAll("[data-wrn-preferences]").forEach(function (switcher) {
if (switcher.contains(event.target)) return;
switcher.querySelectorAll(".wire-preferences__menu[open]").forEach(function (menu) {
switcher.querySelectorAll(".wrn-preferences__menu[open]").forEach(function (menu) {
menu.removeAttribute("open");
});
});
});
document.addEventListener("keydown", function (event) {
if (event.key !== "Escape") return;
document.querySelectorAll("[data-wrn-preferences] .wire-preferences__menu[open]").forEach(function (menu) {
document.querySelectorAll("[data-wrn-preferences] .wrn-preferences__menu[open]").forEach(function (menu) {
menu.removeAttribute("open");
var summary = menu.querySelector(":scope > summary");
if (summary) summary.focus();
@@ -3648,7 +3648,7 @@ export const REACTIVE_RUNTIME = String.raw`
var current = window.location.pathname.replace(/\/+$/, "") || "/";
var best = null;
var bestLength = -1;
navbar.querySelectorAll(".wire-navbar__menus a[href]").forEach(function (link) {
navbar.querySelectorAll(".wrn-navbar__menus a[href]").forEach(function (link) {
var url;
try { url = new URL(link.getAttribute("href"), window.location.origin); } catch (_) { return; }
if (url.origin !== window.location.origin) return;
@@ -3658,12 +3658,12 @@ export const REACTIVE_RUNTIME = String.raw`
best = link;
bestLength = path.length;
});
navbar.querySelectorAll(".wire-navbar__menus [aria-current='page']").forEach(function (item) {
navbar.querySelectorAll(".wrn-navbar__menus [aria-current='page']").forEach(function (item) {
item.removeAttribute("aria-current");
});
if (best) {
best.setAttribute("aria-current", "page");
var parentMenu = best.closest(".wire-navbar__dropdown");
var parentMenu = best.closest(".wrn-navbar__dropdown");
var parentSummary = parentMenu && parentMenu.querySelector(":scope > summary");
if (parentSummary) parentSummary.setAttribute("aria-current", "page");
}
@@ -3675,13 +3675,13 @@ export const REACTIVE_RUNTIME = String.raw`
typeof window.matchMedia !== "function" ||
window.matchMedia("(hover: hover) and (pointer: fine)").matches;
if (hoverEnabled && hoverCapable) {
navbar.querySelectorAll(".wire-navbar__dropdown").forEach(function (menu) {
navbar.querySelectorAll(".wrn-navbar__dropdown").forEach(function (menu) {
menu.addEventListener("pointerenter", function () {
if (menu.__wrnNavbarCloseTimer) {
clearTimeout(menu.__wrnNavbarCloseTimer);
menu.__wrnNavbarCloseTimer = null;
}
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (candidate) {
navbar.querySelectorAll(".wrn-navbar__dropdown[open]").forEach(function (candidate) {
if (candidate !== menu) candidate.removeAttribute("open");
});
menu.setAttribute("open", "");
@@ -3698,7 +3698,7 @@ export const REACTIVE_RUNTIME = String.raw`
navbar.addEventListener("toggle", function (event) {
var opened = event.target;
if (!opened || opened.tagName !== "DETAILS" || !opened.open) return;
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (menu) {
navbar.querySelectorAll(".wrn-navbar__dropdown[open]").forEach(function (menu) {
if (menu !== opened) menu.removeAttribute("open");
});
}, true);
@@ -3709,14 +3709,14 @@ export const REACTIVE_RUNTIME = String.raw`
document.addEventListener("pointerdown", function (event) {
document.querySelectorAll("[data-wrn-navbar]").forEach(function (navbar) {
if (navbar.contains(event.target)) return;
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (menu) {
navbar.querySelectorAll(".wrn-navbar__dropdown[open]").forEach(function (menu) {
menu.removeAttribute("open");
});
});
});
document.addEventListener("keydown", function (event) {
if (event.key !== "Escape") return;
document.querySelectorAll("[data-wrn-navbar] .wire-navbar__dropdown[open]").forEach(function (menu) {
document.querySelectorAll("[data-wrn-navbar] .wrn-navbar__dropdown[open]").forEach(function (menu) {
menu.removeAttribute("open");
var summary = menu.querySelector(":scope > summary");
if (summary) summary.focus();
@@ -3748,7 +3748,7 @@ export const REACTIVE_RUNTIME = String.raw`
function syncComboboxInput(root) {
if (!root || !root.hasAttribute("data-wrn-combobox")) return;
var input = root.querySelector(".wire-next__combobox-input");
var input = root.querySelector(".wrn-next__combobox-input");
var api = selectScopeApi(root);
if (!input || !api) return;
var value = api.call("inputText") || "";
@@ -3782,17 +3782,17 @@ export const REACTIVE_RUNTIME = String.raw`
}
function renderRemoteSelectOptions(root, options) {
var list = root.querySelector(".wire-next__select-list");
var list = root.querySelector(".wrn-next__select-list");
if (!list) return;
list.querySelectorAll(".wire-next__option-group, .wire-next__select-option, .wire-next__select-message")
list.querySelectorAll(".wrn-next__option-group, .wrn-next__select-option, .wrn-next__select-message")
.forEach(function (node) { node.remove(); });
options.forEach(function (option) {
if (!option || option.value == null) return;
var button = document.createElement("button");
button.type = "button";
button.className = "wire-next__select-option";
button.className = "wrn-next__select-option";
button.setAttribute("role", "option");
button.setAttribute("data-option-value", String(option.value));
button.disabled = !!option.disabled;
@@ -3809,7 +3809,7 @@ export const REACTIVE_RUNTIME = String.raw`
button.appendChild(avatar);
} else if (option.color) {
var dot = document.createElement("i");
dot.className = "wire-next__color-dot";
dot.className = "wrn-next__color-dot";
dot.style.setProperty("--option-color", String(option.color));
button.appendChild(dot);
}
@@ -3826,7 +3826,7 @@ export const REACTIVE_RUNTIME = String.raw`
button.appendChild(copy);
var check = document.createElement("i");
check.className = "wire-next__check icon-[lucide--check]";
check.className = "wrn-next__check icon-[lucide--check]";
check.setAttribute("aria-hidden", "true");
check.style.display = "none";
button.appendChild(check);
@@ -3837,7 +3837,7 @@ export const REACTIVE_RUNTIME = String.raw`
api.call("chooseOption", option);
window.setTimeout(function () {
var selected = api.call("isSelected", option);
button.classList.toggle("wire-next__select-option--selected", !!selected);
button.classList.toggle("wrn-next__select-option--selected", !!selected);
button.setAttribute("aria-selected", selected ? "true" : "false");
check.style.display = selected ? "" : "none";
syncComboboxInput(root);
@@ -3853,8 +3853,8 @@ export const REACTIVE_RUNTIME = String.raw`
var remote = root.getAttribute("data-remote") === "true";
var remoteUrl = root.getAttribute("data-remote-url") || "";
var input = root.querySelector(".wire-next__select-search input, .wire-next__combobox-input");
var list = root.querySelector(".wire-next__select-list");
var input = root.querySelector(".wrn-next__select-search input, .wrn-next__combobox-input");
var list = root.querySelector(".wrn-next__select-list");
var loadMore = root.querySelector("[data-wrn-select-load-more]");
var timer = 0;
var requestId = 0;
@@ -3968,12 +3968,12 @@ export const REACTIVE_RUNTIME = String.raw`
root.addEventListener("click", function (event) {
if (!remote || !remoteUrl) return;
if (!event.target.closest(".wire-next__select-trigger")) return;
if (!event.target.closest(".wrn-next__select-trigger")) return;
if (loadedOptions.length === 0) load(false);
});
root.__wrnexusSelectController.load = load;
var dropdown = root.querySelector(".wire-next__select-dropdown");
var dropdown = root.querySelector(".wrn-next__select-dropdown");
var lastOpen = !!(selectScopeApi(root) && selectScopeApi(root).get("open"));
function emitOpenStateIfChanged() {
var api = selectScopeApi(root);
@@ -3998,7 +3998,7 @@ export const REACTIVE_RUNTIME = String.raw`
}
root.addEventListener("click", function (event) {
var optionButton = event.target.closest(".wire-next__select-option");
var optionButton = event.target.closest(".wrn-next__select-option");
if (optionButton) {
window.setTimeout(function () {
var api = selectScopeApi(root);
@@ -4012,7 +4012,7 @@ export const REACTIVE_RUNTIME = String.raw`
emitOpenStateIfChanged();
}, 0);
}
if (event.target.closest(".wire-next__clear-select")) {
if (event.target.closest(".wrn-next__clear-select")) {
window.setTimeout(function () {
emitSelectEvent(root, "clear");
emitSelectEvent(root, "change", { reason: "clear" });
@@ -4064,7 +4064,7 @@ export const REACTIVE_RUNTIME = String.raw`
},
};
root.addEventListener("click", function (event) {
if (!event.target.closest(".wire-next__select-option, .wire-next__clear-select")) return;
if (!event.target.closest(".wrn-next__select-option, .wrn-next__clear-select")) return;
window.setTimeout(function () { syncComboboxInput(root); }, 0);
});
if (input) {
@@ -4093,7 +4093,7 @@ export const REACTIVE_RUNTIME = String.raw`
if (!selectOutsideClickBound) {
selectOutsideClickBound = true;
document.addEventListener("pointerdown", function (event) {
document.querySelectorAll("[data-wrn-select].wire-next--open").forEach(function (select) {
document.querySelectorAll("[data-wrn-select].wrn-next--open").forEach(function (select) {
if (select.contains(event.target)) return;
var api = selectScopeApi(select);
if (api) api.set("open", false);
@@ -4139,7 +4139,7 @@ export const REACTIVE_RUNTIME = String.raw`
function callServerFunction(component, functionName, args) {
var csrfMeta = document.querySelector('meta[name="wrnexus-csrf"]');
var csrfMatch = /(?:^|;\s*)wire-csrf=([^;]+)/.exec(document.cookie || "");
var csrfMatch = /(?:^|;\s*)wrn-csrf=([^;]+)/.exec(document.cookie || "");
var csrf = csrfMeta
? csrfMeta.getAttribute("content") || ""
: csrfMatch
+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); });
+1 -1
View File
@@ -17,7 +17,7 @@ export class WrnServerCallError extends Error {
function csrfFromCookie(): string | undefined {
if (typeof document === "undefined") return undefined;
const raw = /(?:^|;\s*)wire-csrf=([^;]+)/.exec(document.cookie)?.[1];
const raw = /(?:^|;\s*)wrn-csrf=([^;]+)/.exec(document.cookie)?.[1];
return raw ? decodeURIComponent(raw) : undefined;
}