@rr0/ufoathome 0.123.0 → 0.123.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ rr0-interview .bar:hover::after, rr0-interview .bar:focus::after { display: bloc
25
25
  rr0-interview .turn .refs { display: flex; flex-wrap: wrap; gap: .25em; }
26
26
  rr0-interview .turn .ref { font: inherit; font-size: .8em; cursor: pointer; border: 1px solid var(--rr0-interview-line); border-radius: 999px; background: transparent; color: inherit;
27
27
  padding: 0 .35em; font-variant-numeric: tabular-nums; white-space: nowrap; }
28
- `;class T extends HTMLElement{messages=x;said=new y(["en"]);localeToken=0;loadToken=0;json;base;status=document.createElement("p");turns=document.createElement("div");blocks=new Map;constructor(){super(),this.status.className="rr0-interview-status",this.status.setAttribute("role","status"),this.turns.className="rr0-interview-turns"}static get observedAttributes(){return["src"]}attributeChangedCallback(e,t,i){e==="src"&&i!==t&&this.isConnected&&this.load()}connectedCallback(){T.styleRoot(this.getRootNode()),this.contains(this.turns)||this.replaceChildren(this.status,this.turns),this.loadLocale(),this.hasAttribute("src")&&this.json===void 0&&this.load()}get interview(){return this.json}set interview(e){this.loadToken++,this.json=e,this.draw()}set documentUrl(e){this.base=e}static styleRoot(e){const t=e instanceof ShadowRoot?e:document.head;if(t.querySelector("style[data-rr0-interview]"))return;const i=document.createElement("style");i.dataset.rr0Interview="",i.textContent=U,t.append(i)}async load(){const e=this.getAttribute("src"),t=++this.loadToken;if(!e)return;const i=new URL(e,location.href).href;let s;try{s=await w.json(i)}catch{s=void 0}t===this.loadToken&&(this.base=i,this.json=s,this.draw())}async loadLocale(){const e=++this.localeToken,t=N.preferencesFor(this),i=F(t,O),s=i==="en"?x:await R(i);e===this.localeToken&&(this.said=new y(t),this.messages=s,this.draw())}speakerName(e,t){const i=g.speakerName(e,t),s=e.speakers?.[t]?.role;return i===s&&s in this.messages.roles?this.messages.roles[s]:i}seek(e){const t=this.json,i={sighting:e.sighting??g.sightingsOf(t)[0],at:e.at};this.dispatchEvent(new CustomEvent(j,{bubbles:!0,composed:!0,detail:i}));const s=this.getAttribute("player");if(!s)return;const c=this.getRootNode().getElementById?.(s);typeof c?.seekTo=="function"&&(c.scrollIntoView?.({block:"center",behavior:"smooth"}),c.seekTo(i.at,i.sighting))}gap(e,t){const i=document.createElement(t),s=document.createElement("span");s.className="bar";const r=`${this.messages.redacted} : ${this.said.read(e)??""}`;return s.dataset.tip=r,s.tabIndex=0,s.setAttribute("role","img"),s.setAttribute("aria-label",r),i.append(s),i}saidNodes(e){if(!/[<&]/.test(e))return[document.createTextNode(e)];const t=document.createElement("template");t.innerHTML=e;for(const i of t.content.querySelectorAll("*")){if(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED"].includes(i.tagName)){i.remove();continue}for(const s of[...i.attributes])if(/^on/i.test(s.name)||/^\s*javascript:/i.test(s.value))i.removeAttribute(s.name);else if(["href","src"].includes(s.name))try{s.value=new URL(s.value,this.base??location.href).href}catch{}}return[...t.content.childNodes]}draw(){const e=this.messages,t=this.json;this.blocks.clear();const i=Array.isArray(t?.segments)?t.segments:[];if(!t||i.length===0){this.status.hidden=!0;const a=document.createElement("p");a.textContent=e.exchangesEmpty,this.turns.replaceChildren(a);return}const s=t.speakers??{},r=Object.keys(s);if(t.proofreading){const a=r.filter(o=>!["approved","covered"].includes(t.proofreading?.[o]?.status??""));this.status.textContent=a.length===0?e.proofreadAll:e.proofreadPending.replace("{names}",a.map(o=>this.speakerName(t,o)).join(", ")),this.status.hidden=!1}else this.status.hidden=!0;const c=[];let n,p;i.forEach((a,o)=>{const h=a.redacted?JSON.stringify(a.redacted.reason):void 0;if(h!==void 0&&n?.reason===h){this.blocks.set(o,n.block);return}const l=document.createElement("div");l.className="turn",l.dataset.segment=String(o),l.style.setProperty("--speaker-hue",String((Math.max(0,r.indexOf(a.speaker))*67+210)%360));const v=document.createElement("div");v.className="who";const A=document.createElement("span");if(A.textContent=a.redacted?"":this.speakerName(t,a.speaker),a.start!==void 0&&(l.dataset.time=g.clock(a.start,!0)),!a.redacted&&p===a.speaker&&l.classList.add("goes-on"),p=a.redacted?void 0:a.speaker,v.append(A),a.redacted){l.classList.add("is-redacted");const u=this.gap(a.redacted.reason,"p");u.className="redacted",n={block:l,reason:h},l.append(v,u)}else{const u=document.createElement("p");if(u.className="said",a.parts){let f="";for(const m of a.parts){const L="redacted"in m?"▮":g.plain(m.text);/[\p{L}\p{N}.,;:!?)»”…▮]$/u.test(f)&&/^[\p{L}\p{N}(«“▮]/u.test(L)&&u.append(" "),"redacted"in m?u.append(this.gap(m.redacted.reason,"span")):u.append(...this.saidNodes(m.text)),f=L}}else u.append(...this.saidNodes(a.text??""));n=void 0,l.append(v,u)}if(a.refs?.length){const u=document.createElement("div");u.className="refs";for(const f of a.refs){const m=document.createElement("button");m.type="button",m.className="ref",m.textContent=`↗ ${g.clock(f.at,!0)}`,m.addEventListener("click",()=>this.seek(f)),u.append(m)}l.append(u)}this.blocks.set(o,l),c.push(l)}),this.turns.replaceChildren(...c)}revealSegment(e){const t=this.blocks.get(e);t&&(t.scrollIntoView?.({block:"center"}),t.classList.add("flash"),window.setTimeout(()=>t.classList.remove("flash"),1600))}}function B(){customElements.get(C)||customElements.define(C,T)}const S="rr0-interview-editor",M=`
28
+ `;class T extends HTMLElement{messages=x;said=new y(["en"]);localeToken=0;loadToken=0;json;loading;base;status=document.createElement("p");turns=document.createElement("div");blocks=new Map;constructor(){super(),this.status.className="rr0-interview-status",this.status.setAttribute("role","status"),this.turns.className="rr0-interview-turns"}static get observedAttributes(){return["src"]}attributeChangedCallback(e,t,i){e==="src"&&i!==t&&this.isConnected&&this.load()}connectedCallback(){T.styleRoot(this.getRootNode()),this.contains(this.turns)||this.replaceChildren(this.status,this.turns),this.loadLocale(),this.hasAttribute("src")&&this.json===void 0&&this.loading!==this.getAttribute("src")&&this.load()}get interview(){return this.json}set interview(e){this.loadToken++,this.json=e,this.draw()}set documentUrl(e){this.base=e}static styleRoot(e){const t=e instanceof ShadowRoot?e:document.head;if(t.querySelector("style[data-rr0-interview]"))return;const i=document.createElement("style");i.dataset.rr0Interview="",i.textContent=U,t.append(i)}async load(){const e=this.getAttribute("src"),t=++this.loadToken;if(this.loading=e??void 0,!e)return;const i=new URL(e,location.href).href;let s;try{s=await w.json(i)}catch{s=void 0}t===this.loadToken&&(this.base=i,this.json=s,this.draw())}async loadLocale(){const e=++this.localeToken,t=N.preferencesFor(this),i=F(t,O),s=i==="en"?x:await R(i);e===this.localeToken&&(this.said=new y(t),this.messages=s,this.draw())}speakerName(e,t){const i=g.speakerName(e,t),s=e.speakers?.[t]?.role;return i===s&&s in this.messages.roles?this.messages.roles[s]:i}seek(e){const t=this.json,i={sighting:e.sighting??g.sightingsOf(t)[0],at:e.at};this.dispatchEvent(new CustomEvent(j,{bubbles:!0,composed:!0,detail:i}));const s=this.getAttribute("player");if(!s)return;const c=this.getRootNode().getElementById?.(s);typeof c?.seekTo=="function"&&(c.scrollIntoView?.({block:"center",behavior:"smooth"}),c.seekTo(i.at,i.sighting))}gap(e,t){const i=document.createElement(t),s=document.createElement("span");s.className="bar";const r=`${this.messages.redacted} : ${this.said.read(e)??""}`;return s.dataset.tip=r,s.tabIndex=0,s.setAttribute("role","img"),s.setAttribute("aria-label",r),i.append(s),i}saidNodes(e){if(!/[<&]/.test(e))return[document.createTextNode(e)];const t=document.createElement("template");t.innerHTML=e;for(const i of t.content.querySelectorAll("*")){if(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED"].includes(i.tagName)){i.remove();continue}for(const s of[...i.attributes])if(/^on/i.test(s.name)||/^\s*javascript:/i.test(s.value))i.removeAttribute(s.name);else if(["href","src"].includes(s.name))try{s.value=new URL(s.value,this.base??location.href).href}catch{}}return[...t.content.childNodes]}draw(){const e=this.messages,t=this.json;this.blocks.clear();const i=Array.isArray(t?.segments)?t.segments:[];if(!t||i.length===0){this.status.hidden=!0;const a=document.createElement("p");a.textContent=e.exchangesEmpty,this.turns.replaceChildren(a);return}const s=t.speakers??{},r=Object.keys(s);if(t.proofreading){const a=r.filter(o=>!["approved","covered"].includes(t.proofreading?.[o]?.status??""));this.status.textContent=a.length===0?e.proofreadAll:e.proofreadPending.replace("{names}",a.map(o=>this.speakerName(t,o)).join(", ")),this.status.hidden=!1}else this.status.hidden=!0;const c=[];let n,p;i.forEach((a,o)=>{const h=a.redacted?JSON.stringify(a.redacted.reason):void 0;if(h!==void 0&&n?.reason===h){this.blocks.set(o,n.block);return}const l=document.createElement("div");l.className="turn",l.dataset.segment=String(o),l.style.setProperty("--speaker-hue",String((Math.max(0,r.indexOf(a.speaker))*67+210)%360));const v=document.createElement("div");v.className="who";const A=document.createElement("span");if(A.textContent=a.redacted?"":this.speakerName(t,a.speaker),a.start!==void 0&&(l.dataset.time=g.clock(a.start,!0)),!a.redacted&&p===a.speaker&&l.classList.add("goes-on"),p=a.redacted?void 0:a.speaker,v.append(A),a.redacted){l.classList.add("is-redacted");const u=this.gap(a.redacted.reason,"p");u.className="redacted",n={block:l,reason:h},l.append(v,u)}else{const u=document.createElement("p");if(u.className="said",a.parts){let f="";for(const m of a.parts){const L="redacted"in m?"▮":g.plain(m.text);/[\p{L}\p{N}.,;:!?)»”…▮]$/u.test(f)&&/^[\p{L}\p{N}(«“▮]/u.test(L)&&u.append(" "),"redacted"in m?u.append(this.gap(m.redacted.reason,"span")):u.append(...this.saidNodes(m.text)),f=L}}else u.append(...this.saidNodes(a.text??""));n=void 0,l.append(v,u)}if(a.refs?.length){const u=document.createElement("div");u.className="refs";for(const f of a.refs){const m=document.createElement("button");m.type="button",m.className="ref",m.textContent=`↗ ${g.clock(f.at,!0)}`,m.addEventListener("click",()=>this.seek(f)),u.append(m)}l.append(u)}this.blocks.set(o,l),c.push(l)}),this.turns.replaceChildren(...c)}revealSegment(e){const t=this.blocks.get(e);t&&(t.scrollIntoView?.({block:"center"}),t.classList.add("flash"),window.setTimeout(()=>t.classList.remove("flash"),1600))}}function B(){customElements.get(C)||customElements.define(C,T)}const S="rr0-interview-editor",M=`
29
29
  <style>
30
30
  :host { display: block; }
31
31
  /* The colours of the transcript's text editor (see SightingFileEditor): a key, a string, a number or a word, and a mistake. Dark mode redefines them. */