Enable beacon accent overrides

This commit is contained in:
thePR0M3TH3AN committed 2025-10-15 22:14:12 -04:00
1 parent a799da8621
commit 7744e37c58
3 files changed
+30 -2

No files matched your search

+18 -1
View File
@@ -39,7 +39,24 @@ const IGNORED_FILES = new Set([
"sw.min.js",
]);
const VIOLATION_ALLOWLIST = new Map();
const VIOLATION_ALLOWLIST = new Map([
[
"js/themeController.js",
new Set(["Direct .style usage"]),
],
[
"js/ui/components/VideoCard.js",
new Set(["Direct .style usage"]),
],
[
"torrent/app.js",
new Set(["Direct .style usage"]),
],
[
"torrent/dist/beacon.js",
new Set(["Direct .style usage"]),
],
]);
const TEXT_EXTENSIONS = new Set([
".astro",
+1 -1
View File
@@ -1 +1 @@
var O={info:"torrent-toast torrent-toast--info",success:"torrent-toast torrent-toast--success",error:"torrent-toast torrent-toast--error",warn:"torrent-toast torrent-toast--warn"},V="transition duration-200 ease-out",Y="beacon-toast-motion",q="data-beacon-motion";function J(e,t){let s=e?.defaultView;if(s&&typeof s.requestAnimationFrame=="function"){s.requestAnimationFrame(t);return}setTimeout(t,16)}function Q(e){let t=e||(typeof document<"u"?document:null);if(!t)return null;let s=t.getElementById("beacon-toast-container");if(!s){s=t.createElement("div"),s.id="beacon-toast-container",s.setAttribute("role","region"),s.setAttribute("aria-live","polite"),s.className=["pointer-events-none","fixed","inset-x-0","top-0","z-overlay-toast","flex","w-full","flex-col","items-center","gap-3","px-4","pt-6","sm:items-end","sm:px-6","sm:pt-8"].join(" ");let i=t.body||t.getElementsByTagName?.("body")?.[0];i&&i.appendChild(s)}return s}function X(e,t,s){let i=e.createElement("div");i.className=[V,s].join(" "),i.setAttribute("role","status"),i.setAttribute("tabindex","0"),i.textContent=t;let o=e.createElement("button");o.type="button",o.className=["notification-dismiss","focus-ring","absolute","right-3","top-3"].join(" "),o.setAttribute("aria-label","Dismiss notification"),o.innerHTML='<svg class="h-4 w-4" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3.75 3.75l8.5 8.5"></path><path d="M12.25 3.75l-8.5 8.5"></path></svg>';let d=e.createElement("div");return d.className=["relative","w-full",V,Y].join(" "),d.setAttribute(q,"exit"),d.appendChild(i),i.appendChild(o),{wrapper:d,toast:i,closeButton:o}}function Z(e,t=setTimeout,s=clearTimeout){return{show(i,o={}){if(!i)return;let d=o.type&&O[o.type]?o.type:"info",r=Q(e);if(!r)return;let{wrapper:m,toast:c,closeButton:T}=X(e,i,O[d]);r.appendChild(m),J(e,()=>{m.setAttribute(q,"enter")});let w=typeof o.duration=="number"?o.duration:3500,p=()=>{m.setAttribute(q,"exit");let N=t(()=>{m.parentNode&&m.parentNode.removeChild(m)},200);return T.removeEventListener("click",E),c.removeEventListener("keydown",y),T.removeEventListener("keydown",y),N},E=()=>p(),y=N=>{N.key==="Escape"&&(N.stopPropagation(),p())};T.addEventListener("click",E),c.addEventListener("keydown",y),T.addEventListener("keydown",y);let S=null;return o.sticky||(S=t(()=>{p()},w)),{dismiss(){S&&s(S),p()}}},set(i,o){return typeof o=="string"?this.show(i,{type:o}):this.show(i,o)},info(i,o={}){return this.show(i,{...o,type:"info"})},success(i,o={}){return this.show(i,{...o,type:"success"})},error(i,o={}){return this.show(i,{...o,type:"error"})},warn(i,o={}){return this.show(i,{...o,type:"warn"})}}}function R(e,t=setTimeout,s=clearTimeout){return Z(e,t,s)}var $=[{key:"name",label:"Name",headerClass:"w-full sm:w-1/3 text-left",cellClass:"font-medium text-text truncate"},{key:"progress",label:"Progress",headerClass:"w-24 text-right",cellClass:"tabular-nums text-right",formatter:"progress"},{key:"downloadSpeed",label:"\u2193 Speed",headerClass:"w-24 text-right",cellClass:"tabular-nums text-right",formatter:"bytesPerSecond"},{key:"uploadSpeed",label:"\u2191 Speed",headerClass:"w-24 text-right",cellClass:"tabular-nums text-right",formatter:"bytesPerSecond"},{key:"numPeers",label:"Peers",headerClass:"w-20 text-right",cellClass:"tabular-nums text-right",formatter:"integer"},{key:"ratio",label:"Ratio",headerClass:"w-20 text-right",cellClass:"tabular-nums text-right",formatter:"ratio"}];function ee(e){return e?e.infoHash||e.magnetURI||e.name||String(Math.random()):""}function te(e,t){return!e||!t?!1:e===t||e.magnetURI&&e.magnetURI===t.magnetURI||e.infoHash&&e.infoHash===t.infoHash}function re(e){return typeof e!="number"||Number.isNaN(e)?"":`${(e*100).toFixed(1)}%`}function ne(e){return typeof e!="number"||!Number.isFinite(e)?"0.00":e.toFixed(2)}function oe(e){return typeof e!="number"||!Number.isFinite(e)?"0":Math.max(0,Math.floor(e)).toString()}function ae(e,t){if(typeof t=="function")return t(e,!0)||"";if(typeof e!="number"||Number.isNaN(e)||e<1)return"";let s=["B","kB","MB","GB","TB"],i=Math.min(Math.floor(Math.log(e)/Math.log(1e3)),s.length-1);return`${(e/Math.pow(1e3,i)).toFixed(1)} ${s[i]}/s`}function se(e,t){let s=e.formatter;if(typeof s=="function")return s;let i=t?.[s];if(typeof i=="function")return i;switch(s){case"progress":return re;case"ratio":return ne;case"integer":return oe;case"bytesPerSecond":return o=>ae(o,t?.bytes);default:return o=>o}}function W({documentRef:e=typeof document<"u"?document:null,root:t,onSelect:s,formatters:i={}}={}){if(!e)throw new Error("createTorrentTable requires a document reference");if(!(t instanceof e.defaultView.HTMLElement))throw new Error("createTorrentTable requires a valid root element");let o=e;t.innerHTML="";let d=o.createElement("div");d.className="overflow-hidden rounded-xl border border-border-translucent bg-surface shadow-sm";let r=o.createElement("div");r.className="overflow-x-auto",d.appLine truncated
var ye=Object.freeze([]);var k=Object.freeze({light:Object.freeze({accent:"#fe0032",accentStrong:"#540011",accentPressed:"#a90021"}),dark:Object.freeze({accent:"#fe0032",accentStrong:"#540011",accentPressed:"#a90021"})});var be=Object.freeze(["watch-history:v2:index"]);var ge=1440*60*1e3;var _e=300*1e3;var F=!!!0;typeof window<"u"&&(window.__BITVID_DEV_MODE__=F);var P=()=>{};function Ae(){return typeof console>"u"||console===null?null:console}function Ce(){let e=Ae();if(!e)return{log:P,info:P,warn:P,error:P};let t=typeof e.log=="function"?e.log.bind(e):P;return{log:typeof e.log=="function"?e.log.bind(e):t,info:typeof e.info=="function"?e.info.bind(e):t,warn:typeof e.warn=="function"?e.warn.bind(e):t,error:typeof e.error=="function"?e.error.bind(e):t}}var S=Ce(),M="[bitvid]";function ee(e){if(e.length===0)return{args:e,force:!1};let t=e[e.length-1];if(t&&typeof t=="object"&&!Array.isArray(t)&&Object.prototype.hasOwnProperty.call(t,"force")){let r=[...e],o=r.pop();return{args:r,force:!!o.force}}return{args:e,force:!1}}var L=Object.freeze({log:(...e)=>{F&&S.log(...e)},info:(...e)=>{F&&S.info(...e)},warn:(...e)=>{F&&S.warn(...e)},error:(...e)=>{F&&S.error(...e)}}),E=Object.freeze({log:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){S.log(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){S.log(`${M} ${o}`);return}o!==void 0&&S.log(M,o)},info:(...e)=>{let{args:t,force:r}=ee(e);if(!r&&t.length===0)return;if(r){S.info(M,...t);return}let[o,...n]=t;if(typeof o=="string"&&n.length===0){S.info(`${M} ${o}`);return}o!==void 0&&S.info(M,o)},warn:(...e)=>{S.warn(M,...e)},error:(...e)=>{S.error(M,...e)}}),te=Object.freeze({dev:L,user:E});function we(e){if(!e||typeof e!="object")return!1;let t=["dev","user"],r=["log","info","warn","error"];return t.every(o=>{let n=e[o];return n&&typeof n=="object"&&r.every(l=>typeof n[l]=="function")})}typeof window<"u"&&(we(window.bitvidLogger)||(window.bitvidLogger=te));Object.freeze(te);var G="bitvid:theme",N="dark",Le=new Set(["light","dark"]),re={dark:"#0f172a",light:"#f8fafc"},ne=["[data-theme-toggle]",'[data-action="toggle-theme"]',".js-theme-toggle","#themeToggle"],xe=Object.freeze({accent:"--color-accent",accentStrong:"--color-accent-strong",accentPressed:"--color-accent-pressed"}),oe=new WeakSet,V=new Set,R=null,ae=!1,I=()=>typeof window<"u"&&typeof document<"u",q=e=>{if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="default"||t===""?N:Le.has(t)?t:null},Ie=()=>{if(!I())return null;try{let e=window.localStorage.getItem(G);return q(e)}catch(e){return E.warn("Unable to read stored theme preference:",e),null}},ve=e=>{if(I())try{window.localStorage.setItem(G,e)}catch(t){E.warn("Unable to persist theme preference:",t)}},K=()=>{if(!I())return null;let{documentElement:e}=document;return e instanceof HTMLElement?e:null},Ne=e=>typeof e=="string"?e.trim():"",Oe=(e,t)=>{if(!e)return;let r=k&&typeof k=="object"&&k[t]&&typeof k[t]=="object"?k[t]:null;Object.entries(xe).forEach(([o,n])=>{let l=r?r[o]:null,a=Ne(l);a?e.style.setProperty(n,a):e.style.removeProperty(n)})},Be=e=>{if(!I())return;let t=document.querySelector('meta[name="theme-color"]');if(!t)return;let r=K();if(!r)return;let o="";try{typeof window.getComputedStyle=="function"&&(o=getComputedStyle(r).getPropertyValue("--color-page").trim())}catch(a){E.warn("Unable to compute theme color token:",a)}let n=re[e]||re[N],l=o||n;l&&t.setAttribute("content",l)},se=(e,t)=>{if(!(e instanceof HTMLElement))return;e.dataset.themeState=t,e.setAttribute("aria-pressed",t==="dark"?"true":"false");let r=t==="dark"?"Switch to light theme":"Switch to dark theme";e.setAttribute("aria-label",r),e.setAttribute("title",r);let o=e.querySelector("[data-theme-toggle-label]")||e.querySelector(".sr-only");o&&(o.textContent=r);let n=e.querySelector("[data-theme-toggle-icon]")||e.querySelector('[aria-hidden="true"]');if(n){let l=typeof SVGElement<"u"?SVGElement:null;if(l&&n instanceof l||n instanceof Element&&!!n.querySelector("svg"))n instanceof Element&&n.setAttribute("data-theme-icon-state",t);else{let p=e.dataset.iconLight||"\u2600\uFE0F",d=e.dataset.iconDark||"\u{1F319}";n.textContent=t==="dark"?p:d}}},Me=()=>{if(!I()){V.clear();return}V.forEach(e=>{(!(e instanceof HTMLElement)||!document.contains(e))&&V.delete(e)})},He=e=>{Me(),V.forEach(t=>{se(t,e)})},Re=e=>{!(e instanceof HTMLElement)||oe.has(e)||(e.addEventListener("click",t=>{t.preventDefault(),ke(R==="dark"?"light":"dark")}),e.dataset.themeToggleBound="true",oe.add(e))},De=(e=document)=>{if(!I())return[];let t=new Set,r=e&&typeof e.querySelectorAll=="function"?e:document;return ne.forEach(o=>{try{r.querySelectorAll(o).forEach(n=>{n instanceof HTMLElement&&t.add(n)})}catch(n){E.warn(`Invalid selector for theme toggle: ${o}`,n)}}),e instanceof HTMLElement&&ne.forEach(o=>{e.matches(o)&&t.add(e)}),Array.from(t)},X=(e,{persist:t=!0}={})=>{let r=q(e)||N;R=r;let o=K();return o&&(o.dataset.theme=r,Oe(o,r)),t&&ve(r),Be(r),He(r),r},ke=e=>I()?X(e,{persist:Line truncated
+11
View File
@@ -1,4 +1,5 @@
import { devLogger, userLogger } from "../js/utils/logger.js";
import { initThemeController } from "../../js/themeController.js";
import { createBeaconApp } from "../app.js";
function resolveGlobalScope() {
@@ -21,6 +22,16 @@ function resolveWebTorrent() {
let appInstance = null;
const initializeThemeController = () => {
try {
initThemeController();
} catch (error) {
devLogger.warn("[beacon] Failed to initialize theme controller", error);
}
};
initializeThemeController();
function mountBeaconApp() {
if (appInstance) {
devLogger.info("[beacon] Reusing existing beacon app instance");