@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.
- package/dist-embed-interview/rr0-interview.mjs +4 -4
- package/dist-embed-scene/rr0-scene.mjs +2 -2
- package/dist-embed-sighting/rr0-sighting.mjs +3 -3
- package/dist-embed-sighting-editor/{InterviewEditorElement-CT26rBmp.js → InterviewEditorElement-Dl2fhE44.js} +1 -1
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +4 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
class w{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const t of this.preferences){const s=e[t]??e[w.base(t)];if(s)return s}const r=new Set(this.preferences.map(t=>w.base(t)));for(const[t,s]of Object.entries(e))if(s&&r.has(w.base(t)))return s;return Object.values(e).find(t=>t)??void 0}write(e,r,t){const s=r?.trim()?r.trim():void 0;if(e===void 0||typeof e=="string")return s;const n={...e},
|
|
2
|
-
`).replace(/<\/?[a-z][^>]*>/gi,"").replace(/&#x([0-9a-f]+);/gi,(r,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);/g,(r,t)=>String.fromCodePoint(Number(t))).replace(/&(\w+);/g,(r,t)=>p.ENTITIES[t.toLowerCase()]??r):e}static sightingsOf(e){return[e.interviewOf].flat().filter(r=>typeof r=="string")}static passagesAbout(e,r){const t=p.sightingsOf(e),s=[];return e.segments.forEach((n,
|
|
1
|
+
class w{constructor(e){this.preferences=e}read(e){if(e===void 0||typeof e=="string")return e===""?void 0:e;for(const t of this.preferences){const s=e[t]??e[w.base(t)];if(s)return s}const r=new Set(this.preferences.map(t=>w.base(t)));for(const[t,s]of Object.entries(e))if(s&&r.has(w.base(t)))return s;return Object.values(e).find(t=>t)??void 0}write(e,r,t){const s=r?.trim()?r.trim():void 0;if(e===void 0||typeof e=="string")return s;const n={...e},a=Object.keys(n).find(o=>o===t)??Object.keys(n).find(o=>w.base(o)===w.base(t))??t;return s===void 0?delete n[a]:n[a]=s,Object.keys(n).length===0?void 0:n}static base(e){return e.toLowerCase().split("-")[0]}}class b extends Error{constructor(e,r,t){super(`${e}: ${r}${t===void 0?"":` (HTTP ${t})`}`),this.kind=e,this.url=r,this.status=t,this.name="SightingFetchError"}}class x{static async json(e){const r=new URL(e,location.href);if(location.protocol==="https:"&&r.protocol==="http:")throw new b("mixed-content",e);let t;try{t=await fetch(e)}catch{throw await this.diagnose(e,r)}if(!t.ok)throw new b("status",e,t.status);try{return await t.json()}catch{throw new b("malformed",e)}}static async diagnose(e,r){if(r.origin===location.origin)return new b("unreachable",e);try{return await fetch(e,{mode:"no-cors"}),new b("cors",e)}catch{return new b("unreachable",e)}}}function A(u,e){for(const r of u){const t=r.toLowerCase().split("-")[0];if(e.includes(t))return t}return"en"}class ${static preferencesFor(e){const r=navigator.languages??[],t=this.declaredFor(e);return t?[t,...r]:r}static declaredFor(e){for(let r=e;r;){const t=r.closest("[lang]")?.getAttribute("lang")?.trim();if(t)return t;const s=r.getRootNode();r=s instanceof ShadowRoot?s.host:void 0}}}const M="modulepreload",O=function(u,e){return new URL(u,e).href},L={},y=function(e,r,t){let s=Promise.resolve();if(r&&r.length>0){let a=function(c){return Promise.all(c.map(f=>Promise.resolve(f).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),i=h?.nonce||h?.getAttribute("nonce");s=a(r.map(c=>{if(c=O(c,t),c in L)return;L[c]=!0;const f=c.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!t)for(let l=o.length-1;l>=0;l--){const g=o[l];if(g.href===c&&(!f||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${d}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":M,f||(m.as="script"),m.crossOrigin="",m.href=c,i&&m.setAttribute("nonce",i),document.head.appendChild(m),f)return new Promise((l,g)=>{m.addEventListener("load",l),m.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return e().catch(n)})},R=["en","fr","es","it"],j={en:()=>y(()=>Promise.resolve().then(()=>P),void 0,import.meta.url).then(u=>u.interviewMessages_en),fr:()=>y(()=>import("./InterviewMessages_fr-CmScqfza.js"),[],import.meta.url).then(u=>u.interviewMessages_fr),es:()=>y(()=>import("./InterviewMessages_es-D5d2JVA3.js"),[],import.meta.url).then(u=>u.interviewMessages_es),it:()=>y(()=>import("./InterviewMessages_it-2SNw5xMp.js"),[],import.meta.url).then(u=>u.interviewMessages_it)};function C(u){return j[u]()}const E={title:"Title",time:"When",by:"Interviewer",medium:"Medium",witness:"Witness",witnessNone:"—",summary:"Description",transcript:"Transcript",transcriptHint:"Address of the anonymised transcript file (optional)",summaryTab:"Summary",fileTab:"File",importFile:"Load a file (JSON, text, WebVTT, SRT)",importUrl:"Or load from URL",importButton:"Load",saveButton:"Save",loading:"Loading the transcript…",invalid:"This text is not valid JSON yet: the interview keeps the last transcript it understood.",notATranscript:"That file is not an interview transcript (it has no segments).",loadFailed:"That transcript could not be read.",editorLabel:"Interview transcript as JSON",byHint:"RR0 people ids, separated by commas",exchangesTab:"Exchanges",exchangesEmpty:"Nothing was said yet.",redacted:"Passage removed",proofreadAll:"Proofread by everyone.",proofreadPending:"Not proofread yet by: {names}",roles:{interviewer:"Interviewer",interviewee:"Interviewee",witness:"Witness"}},P=Object.freeze(Object.defineProperty({__proto__:null,interviewMessages_en:E},Symbol.toStringTag,{value:"Module"})),_="interviewseek";class p{static isProofread(e){const r=Object.keys(e.speakers);return r.length>0&&r.every(t=>{const s=e.proofreading?.[t]?.status;return s==="approved"||s==="covered"})}static said(e){return e.parts?e.parts.map(r=>"redacted"in r?"…":p.plain(r.text)).join(" "):e.redacted?void 0:p.plain(e.text??"")}static ENTITIES={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};static plain(e){return/[<&]/.test(e)?e.replace(/<br\s*\/?>/gi,`
|
|
2
|
+
`).replace(/<\/?[a-z][^>]*>/gi,"").replace(/&#x([0-9a-f]+);/gi,(r,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);/g,(r,t)=>String.fromCodePoint(Number(t))).replace(/&(\w+);/g,(r,t)=>p.ENTITIES[t.toLowerCase()]??r):e}static sightingsOf(e){return[e.interviewOf].flat().filter(r=>typeof r=="string")}static passagesAbout(e,r){const t=p.sightingsOf(e),s=[];return e.segments.forEach((n,a)=>{for(const o of n.refs??[]){if(o.sighting===void 0?!t.includes(r):o.sighting!==r)continue;const h=p.said(n);s.push({index:a,speaker:n.speaker,at:o.at,...h!==void 0?{text:h}:{},...o.range?{range:o.range}:{}})}}),s.sort((n,a)=>n.at-a.at||n.index-a.index)}static clock(e,r=!1){const t=Math.round(e*10),s=Math.floor(t/10),n=h=>String(h).padStart(2,"0"),a=Math.floor(s/3600),o=`${a>0||r?n(Math.floor(s/60)%60):Math.floor(s/60)}:${n(s%60)}`;return`${a>0?`${a}:`:""}${o}${r||t%10!==0?`.${t%10}`:""}`}static speakerName(e,r){const t=e.speakers[r];if(!t)return r;const s=typeof t.title=="string"?t.title:t.title?Object.values(t.title)[0]:void 0;return s||t.by&&p.agentName(t.by)||t.role}static agentName(e){if("people"in e){const[r,...t]=e.people.replace(/([a-z])([A-Z])/g,"$1 $2").split(" ");return[...t,r].join(" ")}return"org"in e?e.org:e.title??""}static stamp(e){const r=Math.round(e*1e3),t=(s,n=2)=>String(s).padStart(n,"0");return`${t(Math.floor(r/36e5))}:${t(Math.floor(r/6e4)%60)}:${t(Math.floor(r/1e3)%60)}.${t(r%1e3,3)}`}static toVtt(e){const r=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),t=e.segments.filter(n=>n.start!==void 0);return`WEBVTT
|
|
3
3
|
|
|
4
|
-
${t.map((n,
|
|
4
|
+
${t.map((n,a)=>{const o=t[a+1],h=n.end??o?.start??n.start+5,i=o&&o.start<h?Math.max(n.start,o.start):h;return`${p.stamp(n.start)} --> ${p.stamp(i)}
|
|
5
5
|
<v ${r(p.speakerName(e,n.speaker))}>${r(p.said(n)??"[…]")}`}).join(`
|
|
6
6
|
|
|
7
7
|
`)}
|
|
@@ -31,4 +31,4 @@ rr0-interview .bar:hover::after, rr0-interview .bar:focus::after { display: bloc
|
|
|
31
31
|
rr0-interview .turn .refs { display: flex; flex-wrap: wrap; gap: .25em; }
|
|
32
32
|
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;
|
|
33
33
|
padding: 0 .35em; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
34
|
-
`;class N extends HTMLElement{messages=E;said=new w(["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,r,t){e==="src"&&t!==r&&this.isConnected&&this.load()}connectedCallback(){N.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 r=e instanceof ShadowRoot?e:document.head;if(r.querySelector("style[data-rr0-interview]"))return;const t=document.createElement("style");t.dataset.rr0Interview="",t.textContent=I,r.append(t)}async load(){const e=this.getAttribute("src"),r=++this.loadToken;if(
|
|
34
|
+
`;class N extends HTMLElement{messages=E;said=new w(["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,r,t){e==="src"&&t!==r&&this.isConnected&&this.load()}connectedCallback(){N.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 r=e instanceof ShadowRoot?e:document.head;if(r.querySelector("style[data-rr0-interview]"))return;const t=document.createElement("style");t.dataset.rr0Interview="",t.textContent=I,r.append(t)}async load(){const e=this.getAttribute("src"),r=++this.loadToken;if(this.loading=e??void 0,!e)return;const t=new URL(e,location.href).href;let s;try{s=await x.json(t)}catch{s=void 0}r===this.loadToken&&(this.base=t,this.json=s,this.draw())}async loadLocale(){const e=++this.localeToken,r=$.preferencesFor(this),t=A(r,R),s=t==="en"?E:await C(t);e===this.localeToken&&(this.said=new w(r),this.messages=s,this.draw())}speakerName(e,r){const t=p.speakerName(e,r),s=e.speakers?.[r]?.role;return t===s&&s in this.messages.roles?this.messages.roles[s]:t}seek(e){const r=this.json,t={sighting:e.sighting??p.sightingsOf(r)[0],at:e.at};this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:t}));const s=this.getAttribute("player");if(!s)return;const a=this.getRootNode().getElementById?.(s);typeof a?.seekTo=="function"&&(a.scrollIntoView?.({block:"center",behavior:"smooth"}),a.seekTo(t.at,t.sighting))}gap(e,r){const t=document.createElement(r),s=document.createElement("span");s.className="bar";const n=`${this.messages.redacted} : ${this.said.read(e)??""}`;return s.dataset.tip=n,s.tabIndex=0,s.setAttribute("role","img"),s.setAttribute("aria-label",n),t.append(s),t}saidNodes(e){if(!/[<&]/.test(e))return[document.createTextNode(e)];const r=document.createElement("template");r.innerHTML=e;for(const t of r.content.querySelectorAll("*")){if(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED"].includes(t.tagName)){t.remove();continue}for(const s of[...t.attributes])if(/^on/i.test(s.name)||/^\s*javascript:/i.test(s.value))t.removeAttribute(s.name);else if(["href","src"].includes(s.name))try{s.value=new URL(s.value,this.base??location.href).href}catch{}}return[...r.content.childNodes]}draw(){const e=this.messages,r=this.json;this.blocks.clear();const t=Array.isArray(r?.segments)?r.segments:[];if(!r||t.length===0){this.status.hidden=!0;const i=document.createElement("p");i.textContent=e.exchangesEmpty,this.turns.replaceChildren(i);return}const s=r.speakers??{},n=Object.keys(s);if(r.proofreading){const i=n.filter(c=>!["approved","covered"].includes(r.proofreading?.[c]?.status??""));this.status.textContent=i.length===0?e.proofreadAll:e.proofreadPending.replace("{names}",i.map(c=>this.speakerName(r,c)).join(", ")),this.status.hidden=!1}else this.status.hidden=!0;const a=[];let o,h;t.forEach((i,c)=>{const f=i.redacted?JSON.stringify(i.redacted.reason):void 0;if(f!==void 0&&o?.reason===f){this.blocks.set(c,o.block);return}const d=document.createElement("div");d.className="turn",d.dataset.segment=String(c),d.style.setProperty("--speaker-hue",String((Math.max(0,n.indexOf(i.speaker))*67+210)%360));const k=document.createElement("div");k.className="who";const m=document.createElement("span");if(m.textContent=i.redacted?"":this.speakerName(r,i.speaker),i.start!==void 0&&(d.dataset.time=p.clock(i.start,!0)),!i.redacted&&h===i.speaker&&d.classList.add("goes-on"),h=i.redacted?void 0:i.speaker,k.append(m),i.redacted){d.classList.add("is-redacted");const l=this.gap(i.redacted.reason,"p");l.className="redacted",o={block:d,reason:f},d.append(k,l)}else{const l=document.createElement("p");if(l.className="said",i.parts){let g="";for(const v of i.parts){const T="redacted"in v?"▮":p.plain(v.text);/[\p{L}\p{N}.,;:!?)»”…▮]$/u.test(g)&&/^[\p{L}\p{N}(«“▮]/u.test(T)&&l.append(" "),"redacted"in v?l.append(this.gap(v.redacted.reason,"span")):l.append(...this.saidNodes(v.text)),g=T}}else l.append(...this.saidNodes(i.text??""));o=void 0,d.append(k,l)}if(i.refs?.length){const l=document.createElement("div");l.className="refs";for(const g of i.refs){const v=document.createElement("button");v.type="button",v.className="ref",v.textContent=`↗ ${p.clock(g.at,!0)}`,v.addEventListener("click",()=>this.seek(g)),l.append(v)}d.append(l)}this.blocks.set(c,d),a.push(d)}),this.turns.replaceChildren(...a)}revealSegment(e){const r=this.blocks.get(e);r&&(r.scrollIntoView?.({block:"center"}),r.classList.add("flash"),window.setTimeout(()=>r.classList.remove("flash"),1600))}}function V(){customElements.get(S)||customElements.define(S,N)}V();
|