@daybook/feedback 1.4.1 → 1.4.3
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/feedback.js +13 -10
- package/dist/index.js +10 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/widget.d.ts +48 -0
- package/dist/widget.js +223 -12
- package/package.json +1 -1
package/dist/feedback.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var DaybookFeedback=(()=>{var D=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Ke=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},Xe=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ze(e))!De.call(n,r)&&r!==t&&D(n,r,{get:()=>e[r],enumerable:!(o=Ue(e,r))||o.enumerable});return n};var Ve=n=>Xe(D({},"__esModule",{value:!0}),n);var $t={};Ke($t,{DEFAULT_API_URL:()=>qe,DaybookFeedback:()=>j,SDK_VERSION:()=>S,captureAnchor:()=>I,init:()=>_t,previewLauncher:()=>Be,resolveAnchor:()=>Se});var S="1.4.1";function L(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var We=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ce(n,e){return n.length===0?"":e&&We.test(e)?"[redacted]":`[${n.length} chars]`}function K(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return K(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",p=n instanceof HTMLInputElement?n.type:e;return`${e}[${p}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function le(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var $="data-daybook-private";var C=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?le(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",K(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",L(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(X).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${X(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${L(de(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${L(de(t[0]))}: ${X(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function de(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function X(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var W="pm.feedback.queue";var H=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,p;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:pe(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await R(i);let s=await i.json(),a=((p=e.attachments)!=null?p:[]).length;return await Promise.all(t.map(async(h,d)=>{let f=Ye(s,a+d);if(!f){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(f,h)}catch(w){o==null||o(h,w)}})),s}async flush(){let e=ue();if(e.length!==0){me([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&V(t)}catch{V(t)}}}queue(e){var t;V({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:pe(),attachments:void 0})}async signIn(){let e=he(64),t=await Je(e),o=he(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,p)=>{let h=setInterval(()=>{i.closed&&(f(),p(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=w=>{if(w.origin!==new URL(this.base()).origin)return;let y=w.data;if((y==null?void 0:y.source)==="daybook-feedback"&&y.state===o){if(f(),y.error||!y.code){p(Object.assign(new Error("Sign-in was refused"),{code:y.error||"refused"}));return}l(y.code)}},f=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await R(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await R(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await R(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Ye(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function V(n){let e=ue();e.push(n),me(e.slice(-20))}function ue(){try{let n=localStorage.getItem(W);return n?JSON.parse(n):[]}catch{return[]}}function me(n){try{n.length===0?localStorage.removeItem(W):localStorage.setItem(W,JSON.stringify(n))}catch{}}async function R(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function pe(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function he(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function Je(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function J(n){var o,r;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:Ge(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(o=window.devicePixelRatio)!=null?o:1},device:Qe(),sdk:{name:"js",version:S}};document.referrer&&(e.referrer=L(document.referrer)),n.app&&(e.app=n.app);let t=(r=n.anchors)!=null?r:[];return t[0]&&(e.anchor=t[0]),t.length>1&&(e.anchors=t),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function Qe(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function Ge(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function be(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?nt():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await et(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var fe=1920,Ze=.82;async function et(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>fe?fe/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await tt(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function tt(n){for(let e of["image/webp","image/jpeg"]){let t=await ge(n,e,Ze);if((t==null?void 0:t.type)===e)return t}return ge(n,"image/png")}function ge(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function nt(){let n=[...document.querySelectorAll(`[${$}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var G=4e5,ye=300,we=600,ve=8e3,ot=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),rt=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],it="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function Z(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var st=(n,e)=>e.length>ye?`${e.slice(0,ye)}\u2026[${e.length}]`:e,Q=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function at(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?ce(o,t.name||t.id||t.type):o}function ke(n,e,t,o){var p,h;if(t.used>G)return!1;if(n.nodeType===3){let d=((p=n.textContent)!=null?p:"").replace(/\s+/g," ");if(!d.trim())return!0;let f=d.length>we?`${d.slice(0,we)}\u2026`:d;return e.push(Q(f)),t.used+=f.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||ot.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute($))return e.push(`<${s} ${$}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${Q(st(d.name,d.value))}"`);let c=at(r,o);c!==null&&a.push(`value="${Q(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",f=d.length>ve?`${d.slice(0,ve)}
|
|
2
|
-
/* \u2026${d.length} chars */`:d;e.push(f),t.used+=f.length}else for(let d of Array.from(r.childNodes))if(!ke(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=
|
|
1
|
+
"use strict";var DaybookFeedback=(()=>{var D=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Ve=(n,e)=>{for(var t in e)D(n,t,{get:e[t],enumerable:!0})},Je=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ye(e))!We.call(n,r)&&r!==t&&D(n,r,{get:()=>e[r],enumerable:!(o=Xe(e,r))||o.enumerable});return n};var Ge=n=>Je(D({},"__esModule",{value:!0}),n);var It={};Ve(It,{DEFAULT_API_URL:()=>Ke,DaybookFeedback:()=>j,SDK_VERSION:()=>S,captureAnchor:()=>F,init:()=>Pt,previewLauncher:()=>qe,resolveAnchor:()=>Se});var S="1.4.3";function L(n){var e;try{let t=new URL(n,location.href);return t.origin===location.origin?t.pathname:`${t.origin}${t.pathname}`}catch{return(e=n.split("?")[0])!=null?e:n}}var Qe=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function ce(n,e){return n.length===0?"":e&&Qe.test(e)?"[redacted]":`[${n.length} chars]`}function K(n){var o,r,i,s,a,c;let e=n.tagName.toLowerCase();if(!n.getAttribute("aria-label")&&!n.getAttribute("data-testid")&&!((o=n.textContent)!=null?o:"").trim()){let l=n.closest("button, a, [role=button], [data-testid], label");if(l&&l!==n)return K(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",p=n instanceof HTMLInputElement?n.type:e;return`${e}[${p}]${l?` name=${l}`:""}`}let t=(c=(s=n.getAttribute("aria-label"))!=null?s:n.getAttribute("data-testid"))!=null?c:((a=n.textContent)!=null?a:"").replace(/\s+/g," ").trim().slice(0,40);return t?`${e} "${t}"`:e}function le(n){return n.replace(/[\w.+-]+@[\w-]+\.[\w.]+/g,"[email]").replace(/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[jwt]").replace(/\bBearer\s+[\w.-]+/gi,"Bearer [redacted]").replace(/\b\d{12,19}\b/g,"[number]").slice(0,500)}var $="data-daybook-private";var R=class{constructor(e=40,t=!0){this.limit=e;this.redact=t;this.entries=[];this.detach=[]}list(){return[...this.entries]}add(e,t){for(this.entries.push({at:new Date().toISOString(),type:e,message:this.redact?le(t):t.slice(0,500)});this.entries.length>this.limit;)this.entries.shift()}start(){let e=a=>{let c=a.target;c instanceof Element&&(c.closest("[data-daybook-feedback]")||this.add("click",K(c)))};document.addEventListener("click",e,{capture:!0,passive:!0}),this.detach.push(()=>document.removeEventListener("click",e,{capture:!0}));let t=history.pushState,o=history.replaceState,r=()=>this.add("nav",L(location.href));history.pushState=(...a)=>{t.apply(history,a),r()},history.replaceState=(...a)=>{o.apply(history,a),r()},window.addEventListener("popstate",r),this.detach.push(()=>{history.pushState=t,history.replaceState=o,window.removeEventListener("popstate",r)});for(let a of["error","warn"]){let c=console[a];console[a]=(...l)=>{this.add("console",`${a}: ${l.map(X).join(" ")}`),c.apply(console,l)},this.detach.push(()=>{console[a]=c})}let i=a=>this.add("console",`uncaught: ${a.message}`),s=a=>this.add("console",`unhandled rejection: ${X(a.reason)}`);window.addEventListener("error",i),window.addEventListener("unhandledrejection",s),this.detach.push(()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",s)}),this.watchFetch()}stop(){for(let e of this.detach.splice(0))e()}watchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch;window.fetch=async(...t)=>{let o=performance.now();try{let r=await e.apply(window,t),i=Math.round(performance.now()-o);return(!r.ok||i>3e3)&&this.add("network",`${r.status} ${L(de(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${L(de(t[0]))}: ${X(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function de(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function X(n){var e,t;if(typeof n=="string")return n;if(n instanceof Error)return`${n.name}: ${n.message}`;try{return(t=(e=JSON.stringify(n))==null?void 0:e.slice(0,200))!=null?t:String(n)}catch{return String(n)}}var W="pm.feedback.queue";var H=class{constructor(e,t){this.apiUrl=e;this.ingestKey=t;this.session=null;this.identityToken=null}setSession(e){this.session=e}async send(e,t=[],o){var c,l,p;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:pe(),...e,attachments:[...(l=e.attachments)!=null?l:[],...t.map(h=>({filename:h.filename,contentType:h.contentType,size:h.blob.size}))]},i=await this.post("/ingest/v1",r);if(!i.ok)throw await P(i);let s=await i.json(),a=((p=e.attachments)!=null?p:[]).length;return await Promise.all(t.map(async(h,d)=>{let f=Ze(s,a+d);if(!f){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(f,h)}catch(w){o==null||o(h,w)}})),s}async flush(){let e=ue();if(e.length!==0){me([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&Y(t)}catch{Y(t)}}}queue(e){var t;Y({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:pe(),attachments:void 0})}async signIn(){let e=he(64),t=await et(e),o=he(16),r=`${this.base()}/ingest/v1/authorize?key=${encodeURIComponent(this.ingestKey)}&origin=${encodeURIComponent(location.origin)}&code_challenge=${encodeURIComponent(t)}&state=${encodeURIComponent(o)}`,i=window.open(r,"daybook-feedback","width=460,height=640");if(!i)throw Object.assign(new Error("Popup blocked"),{code:"popup_blocked"});let s=await new Promise((l,p)=>{let h=setInterval(()=>{i.closed&&(f(),p(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),d=w=>{if(w.origin!==new URL(this.base()).origin)return;let y=w.data;if((y==null?void 0:y.source)==="daybook-feedback"&&y.state===o){if(f(),y.error||!y.code){p(Object.assign(new Error("Sign-in was refused"),{code:y.error||"refused"}));return}l(y.code)}},f=()=>{clearInterval(h),window.removeEventListener("message",d)};window.addEventListener("message",d)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await P(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}base(){return this.apiUrl.replace(/\/$/,"")}resolve(e){try{let t=new URL(this.base()),o=new URL(e,t);return o.hostname===t.hostname?new URL(o.pathname+o.search,t).toString():o.toString()}catch{return e}}async handshake(e){var r,i;let t=await this.post("/ingest/v1/session",{...e,identityToken:(r=this.identityToken)!=null?r:void 0});if(!t.ok)throw await P(t);let o=await t.json();return this.session=(i=o.sessionToken)!=null?i:null,o}post(e,t){let o={"Content-Type":"application/json","X-Ingest-Key":this.ingestKey};return this.session&&(o["X-Feedback-Session"]=this.session),fetch(`${this.base()}${e}`,{method:"POST",headers:o,body:JSON.stringify(t),credentials:"omit"})}async upload(e,t){let o=await fetch(this.resolve(e.uploadUrl),{method:e.method,headers:{"Content-Type":e.contentType,"X-Ingest-Key":this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await P(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Ze(n,e){let t=n.attachments.find(o=>o.index===e);return t!=null?t:n.attachments.some(o=>typeof o.index=="number")?void 0:n.attachments[e]}function Y(n){let e=ue();e.push(n),me(e.slice(-20))}function ue(){try{let n=localStorage.getItem(W);return n?JSON.parse(n):[]}catch{return[]}}function me(n){try{n.length===0?localStorage.removeItem(W):localStorage.setItem(W,JSON.stringify(n))}catch{}}async function P(n){let e=`http_${n.status}`;try{let t=await n.json();if(t.code&&(e=t.code),t.message)return Object.assign(new Error(t.message),{code:e})}catch{}return Object.assign(new Error(`Ingest failed (${n.status})`),{code:e})}function pe(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function he(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function et(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function J(n){var o,r;let e={platform:"web",route:location.pathname,title:document.title.slice(0,200),locale:navigator.language,timezone:nt(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(o=window.devicePixelRatio)!=null?o:1},device:tt(),sdk:{name:"js",version:S}};document.referrer&&(e.referrer=L(document.referrer)),n.app&&(e.app=n.app);let t=(r=n.anchors)!=null?r:[];return t[0]&&(e.anchor=t[0]),t.length>1&&(e.anchors=t),n.breadcrumbs&&n.breadcrumbs.length>0&&(e.breadcrumbs=n.breadcrumbs),e}function tt(){var r;let n=navigator.userAgent,e=/Edg\//.test(n)?"Edge":/OPR\//.test(n)?"Opera":/Firefox\//.test(n)?"Firefox":/Chrome\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Unknown",t=/Windows NT/.test(n)?"Windows":/iPhone|iPad|iPod/.test(n)?"iOS":/Mac OS X/.test(n)?"macOS":/Android/.test(n)?"Android":/Linux/.test(n)?"Linux":"Unknown",o=(r=n.match(/(?:Edg|OPR|Firefox|Chrome|Version)\/(\d+)/))==null?void 0:r[1];return{browser:o?`${e} ${o}`:e,os:t,touch:navigator.maxTouchPoints>0,userAgent:n.slice(0,300)}}function nt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function be(n,e=()=>()=>{}){var i;if(typeof((i=navigator.mediaDevices)==null?void 0:i.getDisplayMedia)!="function")return null;let t=n?st():()=>{},o=e(),r=null;try{return r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),r.getVideoTracks()[0]?(await new Promise(a=>setTimeout(a,250)),await rt(r)):null}catch{return null}finally{r==null||r.getTracks().forEach(s=>s.stop()),o(),t()}}var fe=1920,ot=.82;async function rt(n){let e=document.createElement("video");e.srcObject=n,e.muted=!0,await e.play().catch(()=>{});let t=e.videoWidth||window.innerWidth,o=e.videoHeight||window.innerHeight,r=t>fe?fe/t:1,i=document.createElement("canvas");i.width=Math.round(t*r),i.height=Math.round(o*r);let s=i.getContext("2d");if(!s)return null;s.imageSmoothingQuality="high",s.drawImage(e,0,0,i.width,i.height),e.pause(),e.srcObject=null;let a=await it(i);if(!a)return null;let c=a.type||"image/png";return{blob:a,filename:`screenshot.${c==="image/webp"?"webp":c==="image/jpeg"?"jpg":"png"}`,contentType:c}}async function it(n){for(let e of["image/webp","image/jpeg"]){let t=await ge(n,e,ot);if((t==null?void 0:t.type)===e)return t}return ge(n,"image/png")}function ge(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function st(){let n=[...document.querySelectorAll(`[${$}]`),...document.querySelectorAll('input[type="password"]')],e=n.map(t=>t.style.filter);return n.forEach(t=>{t.style.filter="blur(12px)"}),()=>{n.forEach((t,o)=>{var r;t.style.filter=(r=e[o])!=null?r:""})}}var Q=4e5,ye=300,we=600,ve=8e3,at=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),ct=["display","position","z-index","opacity","visibility","overflow","width","height","margin","padding","box-sizing","color","background-color","border","border-radius","box-shadow","font-family","font-size","font-weight","line-height","text-align","white-space","flex-direction","justify-content","align-items","gap","grid-template-columns","transform","transition","pointer-events","cursor"],lt="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, and data-daybook-private subtrees are withheld. html is last because only the head of this file is inlined beside the report \u2014 download the attachment for the rest of it.";function Z(n){let e=[],t=n;for(let o=0;t&&o<4&&t.nodeType===1;o+=1){let r=t.localName;if(t.id){e.unshift(`${r}#${t.id}`);break}let i=Array.from(t.classList).slice(0,3).join(".");i&&(r+=`.${i}`),e.unshift(r),t=t.parentElement}return e.join(" > ")}var dt=(n,e)=>e.length>ye?`${e.slice(0,ye)}\u2026[${e.length}]`:e,G=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function pt(n,e){let t=n;if(n.localName==="input"&&(t.type==="checkbox"||t.type==="radio"))return t.checked?"checked":"unchecked";let o=t.value;return typeof o!="string"||o===""?null:e?ce(o,t.name||t.id||t.type):o}function ke(n,e,t,o){var p,h;if(t.used>Q)return!1;if(n.nodeType===3){let d=((p=n.textContent)!=null?p:"").replace(/\s+/g," ");if(!d.trim())return!0;let f=d.length>we?`${d.slice(0,we)}\u2026`:d;return e.push(G(f)),t.used+=f.length,!0}if(n.nodeType!==1)return!0;let r=n,i=r.tagName;if(r.hasAttribute("data-daybook-feedback")||at.has(i))return!0;let s=r.localName;if(o&&r.hasAttribute($))return e.push(`<${s} ${$}>[withheld]</${s}>`),t.used+=32,!0;let a=[];for(let d of Array.from(r.attributes))d.name!=="value"&&a.push(`${d.name}="${G(dt(d.name,d.value))}"`);let c=pt(r,o);c!==null&&a.push(`value="${G(c)}"`);let l=a.length>0?`<${s} ${a.join(" ")}>`:`<${s}>`;if(e.push(l),t.used+=l.length,s==="style"){let d=(h=r.textContent)!=null?h:"",f=d.length>ve?`${d.slice(0,ve)}
|
|
2
|
+
/* \u2026${d.length} chars */`:d;e.push(f),t.used+=f.length}else for(let d of Array.from(r.childNodes))if(!ke(d,e,t,o))break;return e.push(`</${s}>`),t.used+=s.length+3,t.used<=Q}function ht(){var e,t;let n=[];for(let o of Array.from((t=(e=document.body)==null?void 0:e.querySelectorAll("*"))!=null?t:[]).slice(0,4e3)){let r=getComputedStyle(o);if(r.position!=="fixed"&&r.position!=="sticky"||r.visibility==="hidden"||r.display==="none"||Number(r.opacity)===0)continue;let i=o.getBoundingClientRect();if(!(i.width<4||i.height<4)&&!o.closest("[data-daybook-feedback]")&&(n.push({selector:Z(o),zIndex:r.zIndex,rect:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)}}),n.length>=20))break}return n}function xe(n){if(!(n!=null&&n.selector))return;let e=null;try{e=document.querySelector(n.selector)}catch{return}if(!e)return;let t=[];for(let o=e;o&&t.length<5;o=o.parentElement){let r=getComputedStyle(o),i={};for(let s of ct){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:Z(o),computed:i})}return{selector:n.selector,path:t}}function ut(){return Array.from(document.styleSheets).slice(0,40).map(n=>{try{return{href:n.href,rules:n.cssRules.length}}catch{return{href:n.href,rules:"unreadable"}}})}function Ee(n,e){var o;let t=n==null?[]:Array.isArray(n)?n:[n];try{let r=[],i={used:0};return ke(document.documentElement,r,i,e),{note:lt,capturedAtUtc:new Date().toISOString(),url:location.href,title:document.title,redacted:e,truncated:i.used>Q,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?Z(document.activeElement):null,anchor:xe((o=t[0])!=null?o:null),anchors:t.length>1?t.map(s=>xe(s)).filter(s=>!!s):void 0,layers:ht(),stylesheets:ut(),html:r.join("")}}catch{return null}}function F(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:I(n/window.innerWidth),offsetY:I(e/window.innerHeight),elementText:null,page:Te()};let o=t.getBoundingClientRect();return{selector:mt(t),offsetX:o.width>0?I((n-o.left)/o.width):0,offsetY:o.height>0?I((e-o.top)/o.height):0,elementText:bt(t),page:Te()}}function Se(n){if(!n.selector)return{x:n.offsetX*window.innerWidth,y:n.offsetY*window.innerHeight};let e=null;try{e=document.querySelector(n.selector)}catch{return null}if(!e)return null;let t=e.getBoundingClientRect();return{x:t.left+n.offsetX*t.width,y:t.top+n.offsetY*t.height}}function mt(n){if(n===document.body)return"body";for(let r of["data-testid","data-test","data-daybook-id","data-cy"]){let i=n.getAttribute(r);if(i){let s=`[${r}="${C(i)}"]`;if(T(s))return s}}if(n.id&&!ee(n.id)){let r=`#${C(n.id)}`;if(T(r))return r}let e=[],t=n;for(;t&&t!==document.body&&e.length<8;){let r=t.tagName.toLowerCase(),i=Array.from(t.classList).filter(c=>!ee(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${C(c)}`).join(""));let s=t.parentElement;if(s){let c=Array.from(s.children).filter(l=>l.tagName===t.tagName);c.length>1&&(r+=`:nth-of-type(${c.indexOf(t)+1})`)}e.unshift(r);let a=e.join(" > ");if(T(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&T(o)?o:ft(n)}function ft(n){let e=[],t=n;for(;t&&t!==document.body&&t!==document.documentElement;){let r=gt(t);if(r&&t!==n){e.unshift(r);break}let i=t.parentElement;if(!i)break;e.unshift(`${t.tagName.toLowerCase()}:nth-child(${Array.from(i.children).indexOf(t)+1})`),t=i}t===document.body&&e.unshift("body");let o=e.join(" > ");return o&&T(o)?o:null}function gt(n){for(let e of["data-testid","data-test","data-daybook-id","data-cy"]){let t=n.getAttribute(e);if(t){let o=`[${e}="${C(t)}"]`;if(T(o))return o}}if(n.id&&!ee(n.id)){let e=`#${C(n.id)}`;if(T(e))return e}return null}function T(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function ee(n){return/^[a-z]{1,3}[0-9a-f]{5,}$/i.test(n)||/--[0-9a-f]{5,}$/i.test(n)||/^_[0-9a-z]{5,}/i.test(n)||/^v-[0-9a-f]{6,}$/i.test(n)||/^ng-/.test(n)||/[0-9a-f]{8,}/i.test(n)}function bt(n){var o,r,i;let t=((r=(o=n.innerText)!=null?o:n.textContent)!=null?r:"").replace(/\s+/g," ").trim();if(!t){let s=(i=n.getAttribute("aria-label"))!=null?i:n.getAttribute("title");return(s==null?void 0:s.trim())||null}return t.length>80?`${t.slice(0,77)}\u2026`:t}function Te(){return location.pathname+location.search}function I(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function C(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var yt=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function Le(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=yt.test(o.type)?o.size>26214400?`Too large (${(o.size/1048576).toFixed(1)} MB, max 25).`:null:"Only images and short videos.";t.push({blob:o,filename:o.name||`pasted-${t.length+1}.${wt(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function _e(n){var o;let e=(o=n.clipboardData)==null?void 0:o.items;if(!e)return[];let t=[];for(let r of e){if(r.kind!=="file")continue;let i=r.getAsFile();i&&t.push(i)}return t}function B(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function wt(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function Ae(n){var o;let t=(o=(typeof n.composedPath=="function"?n.composedPath():[])[0])!=null?o:n.target;return!t||t.nodeType!==1?!1:/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)?!0:typeof t.closest=="function"&&t.closest('[contenteditable=""], [contenteditable="true"]')!==null}function vt(n,e,t){let o=0;for(let s of e){if(s.right<=n.left||s.left>=n.right)continue;let a=n.v==="bottom"?t.height-s.top:s.bottom;a>o&&(o=a)}if(o===0)return 0;let r=n.v==="bottom"?t.height-n.bottom:n.top,i=Math.round(o+12-r);return i<=0||i>t.height*.35?0:i}function xt(n,e,t){if(n===e||e.contains(n)||n.contains(e)||n===document.body||n===document.documentElement)return!1;let o=getComputedStyle(n);if(o.position!=="fixed"&&o.position!=="sticky"||o.visibility==="hidden"||o.display==="none"||Number(o.opacity)===0)return!1;let r=n.getBoundingClientRect();return!(r.width<8||r.height<8||r.width*r.height>t.width*t.height*.25)}function kt(n,e,t){if(typeof document.elementsFromPoint!="function")return[];let o=new Map,r=[];for(let s=n.left+4;s<n.right;s+=32)r.push(s);r.push(n.right-4);let i=t.height*.35;for(let s=0;s<=i;s+=32){let a=n.v==="bottom"?n.bottom-s:n.top+s;if(a<0||a>t.height)break;for(let c of r)if(!(c<0||c>t.width))for(let l of document.elementsFromPoint(c,a)){if(o.has(l)||!xt(l,e,t))continue;let p=l.getBoundingClientRect();o.set(l,{top:p.top,bottom:p.bottom,left:p.left,right:p.right})}}return[...o.values()]}function Me(n,e){let t={width:window.innerWidth,height:window.innerHeight};return vt(n,kt(n,e,t),t)}var O=class{constructor(e,t){this.options=e;this.onSubmit=t;this.mode="idle";this.pins=[];this.cancelAdding=null;this.unmark=null;this.detach=[];this.buttonStyle="pill";this.clearance=0;this.state="ready";this.policy=null;this.redrawMarks=null;this.dragged=null;this.launcherAt=Lt();this.swallowClick=!1;this.reference=null;this.uploadsFailed=0;this.host=document.createElement("div"),this.host.setAttribute("data-daybook-feedback",""),this.host.style.cssText="position:fixed;inset:0;z-index:2147483000;pointer-events:none",this.root=this.host.attachShadow({mode:"open"}),this.root.innerHTML=`<style>${De}</style><style id="theme"></style><style id="place"></style><div id="layer"></div>`}setTheme(e){let t=this.root.getElementById("theme");if(t){if(!e){t.textContent="";return}t.textContent=Ne(e),this.buttonStyle=Oe(e),this.themePlacement=e.position,this.applyPlacement(),this.launcherLabel=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):void 0}}get placement(){var e,t;return(t=(e=this.options.placement)!=null?e:this.themePlacement)!=null?t:"bottom-right"}applyPlacement(){let e=this.root.getElementById("place");if(!e)return;let t=this.placement,o=t.startsWith("bottom")?"bottom":"top",r=t.endsWith("right")?"right":"left",i=b+this.clearance;e.textContent=`:host {
|
|
3
3
|
--pm-${r}: ${b}px; --pm-${r==="right"?"left":"right"}: auto;
|
|
4
4
|
--pm-${o}: ${i}px; --pm-${o==="bottom"?"top":"bottom"}: auto;
|
|
5
|
-
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-b:b+t,i=e.startsWith("bottom")?window.innerHeight-b:b+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle")try{let i
|
|
5
|
+
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-b:b+t,i=e.startsWith("bottom")?window.innerHeight-b:b+o;return{left:r-t,right:r,top:i-o,bottom:i,v:e.startsWith("bottom")?"bottom":"top"}}watchClearance(){if(this.options.avoidOverlap===!1)return;let e=!1,t=()=>{if(e=!1,this.mode==="idle"&&!this.launcherAt)try{let i=Me(this.homeSlot(),this.host);if(Math.abs(i-this.clearance)<4)return;this.clearance=i,this.applyPlacement()}catch{}},o=typeof requestAnimationFrame=="function"?i=>requestAnimationFrame(i):i=>setTimeout(i,16),r=()=>{e||(e=!0,o(t))};if(window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r),this.detach.push(()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}),typeof MutationObserver=="function"){let i=new MutationObserver(r);i.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden"]}),this.detach.push(()=>i.disconnect())}r()}setState(e){this.state=e,this.host.isConnected&&this.render()}shield(){let e=o=>{let r=o.composedPath();if(!r.includes(this.host))return;o.stopImmediatePropagation();let[i]=r;if(!(!(i instanceof Node)||i===this.host)){if(o.type==="focusin")i.dispatchEvent(new FocusEvent("focusin",{bubbles:!0,composed:!1}));else if(o.type==="click"&&o instanceof MouseEvent){let s=new MouseEvent("click",{bubbles:!0,cancelable:!0,composed:!1,detail:o.detail,screenX:o.screenX,screenY:o.screenY,clientX:o.clientX,clientY:o.clientY,button:o.button,buttons:o.buttons,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey,altKey:o.altKey,metaKey:o.metaKey});s.preventDefault(),i.dispatchEvent(s)}}};for(let o of $e)window.addEventListener(o,e,!0);this.detach.push(()=>{for(let o of $e)window.removeEventListener(o,e,!0)});let t=o=>o.stopPropagation();for(let o of["keydown","keyup","keypress"])this.root.addEventListener(o,t)}mount(){var e;if(document.body.appendChild(this.host),this.applyPlacement(),this.render(),this.watchClearance(),this.watchLauncher(),this.options.hotkey!==null){let t=((e=this.options.hotkey)!=null?e:"f").toLowerCase(),o=r=>{if(r.key==="Escape"&&this.cancelAdding){this.cancelAdding();return}if(r.key==="Escape"){this.mode==="picking"&&(this.mode="idle",this.pins=[],this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||Ae(r)||this.mode!=="composing"&&r.key.toLowerCase()===t&&(this.mode=this.mode==="picking"?"idle":"picking",this.render())};window.addEventListener("keydown",o),this.detach.push(()=>window.removeEventListener("keydown",o)),this.root.addEventListener("keydown",o)}this.shield()}unmount(){for(let e of this.detach.splice(0))e();this.host.remove()}open(){this.mode="picking",this.render()}setReporter(e){this.reporter=e}setPolicy(e){this.policy=e}capture(){var t,o;let e=(t=this.options.screenshots)!=null?t:!0;return e===!1||((o=this.policy)==null?void 0:o.screenshots)===!1?{offered:!1,checked:!1}:{offered:!0,checked:e!=="optional"}}conceal(){let e=this.root.getElementById("layer"),t=e.style.visibility;e.style.visibility="hidden";let o=this.ringPins();return()=>{e.style.visibility=t,o.forEach(r=>r.remove())}}ringPins(){let e=this.pins.length>1;return this.pins.flatMap((t,o)=>{let r=this.pinRect(t);if(!r)return[];let i=this.origin(),s=document.createElement("div");if(s.className="ring",s.style.left=`${r.left-i.left-k}px`,s.style.top=`${r.top-i.top-k}px`,s.style.width=`${r.width+k*2}px`,s.style.height=`${r.height+k*2}px`,e){let a=document.createElement("span");a.className="ring__n",a.textContent=String(o+1),s.appendChild(a)}return this.root.appendChild(s),[s]})}pinRect(e){var o,r;if(((o=e.anchor.page)!=null?o:Re())!==Re())return null;let t=(r=e.element)!=null&&r.isConnected?e.element:null;if(!t&&e.anchor.selector&&e.anchor.selector!=="body")try{t=document.querySelector(e.anchor.selector)}catch{t=null}if(t){let i=t.getBoundingClientRect();if(i.width>=1&&i.height>=1)return{left:i.left,top:i.top,width:i.width,height:i.height}}return{left:e.box.left-window.scrollX,top:e.box.top-window.scrollY,width:e.box.width,height:e.box.height}}origin(){let e=this.host.getBoundingClientRect();return{left:e.left,top:e.top}}markPins(e){var s;(s=this.unmark)==null||s.call(this);let t=document.createElement("div");e.appendChild(t);let o=0,r=()=>{if(o=0,t.innerHTML="",this.pins.length<1)return;let a=this.origin();this.pins.forEach((c,l)=>{let p=this.pinRect(c);if(!p)return;let h=document.createElement("div");h.className="marker",h.style.left=`${p.left-a.left-k}px`,h.style.top=`${p.top-a.top-k}px`,h.style.width=`${p.width+k*2}px`,h.style.height=`${p.height+k*2}px`;let d=document.createElement("span");d.className="marker__n",d.textContent=String(l+1),h.appendChild(d),t.appendChild(h)})},i=()=>{o||(o=requestAnimationFrame(r))};window.addEventListener("scroll",i,{capture:!0,passive:!0}),window.addEventListener("resize",i),r(),this.redrawMarks=r,this.unmark=()=>{o&&cancelAnimationFrame(o),window.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("resize",i),t.remove(),this.redrawMarks=null,this.unmark=null}}pickAnother(e,t){let o=this.root.getElementById("layer"),r=()=>{var s;i.remove(),e.style.visibility="",this.cancelAdding=null,(s=this.redrawMarks)==null||s.call(this)},i=this.picker(s=>{this.pins.push(s),r(),t()},`Click what else is involved (pin ${this.pins.length+1})`);e.style.visibility="hidden",this.cancelAdding=r,o.appendChild(i)}movable(e,t){this.place(e),t.classList.add("drag"),t.title="Drag to move \xB7 double-click to reset",t.addEventListener("dblclick",()=>{this.dragged=null,this.place(e)}),t.addEventListener("pointerdown",o=>{if(o.target.closest("button")||o.button!==0)return;o.preventDefault();let r=e.getBoundingClientRect(),i=o.clientX-r.left,s=o.clientY-r.top;t.setPointerCapture(o.pointerId),e.classList.add("panel--dragging");let a=l=>{let p=_(l.clientX-i,b-r.width+te,window.innerWidth-te),h=_(l.clientY-s,0,window.innerHeight-te);e.style.left=`${p}px`,e.style.top=`${h}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{t.releasePointerCapture(o.pointerId),t.removeEventListener("pointermove",a),t.removeEventListener("pointerup",c),t.removeEventListener("pointercancel",c),e.classList.remove("panel--dragging"),this.dragged=He(e.getBoundingClientRect()),this.place(e)};t.addEventListener("pointermove",a),t.addEventListener("pointerup",c),t.addEventListener("pointercancel",c)})}place(e){let t=this.dragged;if(!t){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}Ce(e,t,e.offsetWidth||380,e.offsetHeight||240)}placeLauncher(e){if(!this.launcherAt){e.style.left=e.style.right=e.style.top=e.style.bottom="";return}Ce(e,this.launcherAt,e.offsetWidth||120,e.offsetHeight||36)}watchLauncher(){let e=()=>{let t=this.root.querySelector(".launcher");t&&this.mode==="idle"&&this.state==="ready"&&this.placeLauncher(t)};window.addEventListener("resize",e),this.detach.push(()=>window.removeEventListener("resize",e))}movableLauncher(e){e.addEventListener("pointerdown",t=>{if(this.swallowClick=!1,t.button!==0)return;let o=e.getBoundingClientRect(),r=t.clientX-o.left,i=t.clientY-o.top,s=!1;e.setPointerCapture(t.pointerId);let a=l=>{if(!s){if(Math.hypot(l.clientX-t.clientX,l.clientY-t.clientY)<St)return;s=!0,e.classList.add("launcher--dragging")}e.style.left=`${_(l.clientX-r,0,window.innerWidth-o.width)}px`,e.style.top=`${_(l.clientY-i,0,window.innerHeight-o.height)}px`,e.style.right="auto",e.style.bottom="auto"},c=()=>{e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId),e.removeEventListener("pointermove",a),e.removeEventListener("pointerup",c),e.removeEventListener("pointercancel",c),s&&(e.classList.remove("launcher--dragging"),this.launcherAt=He(e.getBoundingClientRect()),_t(this.launcherAt),this.placeLauncher(e),this.swallowClick=!0)};e.addEventListener("pointermove",a),e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c)})}render(){var o;let e=this.root.getElementById("layer");if((o=this.unmark)==null||o.call(this),this.cancelAdding=null,e.innerHTML="",this.mode==="idle"){if(this.state==="pending"){e.appendChild(this.pending());return}let r=this.launcher();e.appendChild(r),this.placeLauncher(r);return}if(this.mode==="sent"){this.dragged=null,e.appendChild(this.sent());return}if(this.mode==="picking"){e.appendChild(this.picker());return}let t=this.composer();e.appendChild(t),this.place(t),this.markPins(e)}pending(){let e=document.createElement("div");return e.className="launcher launcher--pending",e.setAttribute("role","status"),e.textContent="Feedback access pending approval",e}sent(){var c;let e=document.createElement("div");e.className="panel panel--sent",e.setAttribute("role","status");let t=this.reference,o=this.uploadsFailed;e.innerHTML=`
|
|
6
6
|
<div class="sent__tick" aria-hidden="true">✓</div>
|
|
7
7
|
<div class="sent__body">
|
|
8
8
|
<div class="panel__title">Thank you \u2014 that is on its way.</div>
|
|
9
9
|
${t?`<div class="sent__ref">
|
|
10
|
-
<code class="sent__id">${
|
|
10
|
+
<code class="sent__id">${N(t)}</code>
|
|
11
11
|
<button type="button" class="sent__copy" data-copy>Copy</button>
|
|
12
12
|
</div>
|
|
13
13
|
<div class="panel__anchor">Quote it if you follow it up.</div>`:""}
|
|
14
14
|
${o>0?`<div class="sent__warn">${o===1?"One attachment could not be uploaded.":`${o} attachments could not be uploaded.`} The report was filed without it.</div>`:""}
|
|
15
15
|
</div>
|
|
16
|
-
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await
|
|
16
|
+
${t?'<button type="button" class="panel__close" data-dismiss aria-label="Dismiss">×</button>':""}`;let r=()=>{this.mode==="sent"&&(this.mode="idle",this.render())},i=window.setTimeout(r,o>0?2e4:t?12e3:6e3),s=()=>window.clearTimeout(i);if(this.detach.push(()=>window.clearTimeout(i)),this.contain(e),this.place(e),!t)return e;e.addEventListener("pointerenter",s),e.addEventListener("focusin",s),(c=e.querySelector("[data-dismiss]"))==null||c.addEventListener("click",r);let a=e.querySelector("[data-copy]");return a&&(a.onclick=async()=>{s();let l=await Tt(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=je(this.buttonStyle,(t=this.launcherLabel)!=null?t:"Feedback");return e.title=(this.options.hotkey===null?"Report a problem":`Report a problem (${((o=this.options.hotkey)!=null?o:"f").toUpperCase()})`)+" \xB7 drag to move",e.onclick=()=>{if(this.swallowClick){this.swallowClick=!1;return}this.mode="picking",this.render()},this.movableLauncher(e),e}picker(e,t="Click the thing that is wrong"){let o=document.createElement("div");o.className="mask",o.innerHTML=`<div class="hover" hidden></div><div class="hint">${N(t)} \xB7 <kbd>Esc</kbd> to cancel</div>`;let r=o.querySelector(".hover"),i=(a,c)=>{o.style.pointerEvents="none";let l=document.elementFromPoint(a,c);return o.style.pointerEvents="",l},s=0;return o.onmousemove=a=>{if(s)return;let{clientX:c,clientY:l}=a;s=requestAnimationFrame(()=>{s=0;let p=i(c,l);if(!p||p===document.body||p===document.documentElement){r.hidden=!0;return}let h=p.getBoundingClientRect(),d=this.origin();r.hidden=!1,r.style.left=`${h.left-d.left}px`,r.style.top=`${h.top-d.top}px`,r.style.width=`${h.width}px`,r.style.height=`${h.height}px`})},o.onclick=a=>{o.style.pointerEvents="none";let c=Mt(a.clientX,a.clientY);if(o.style.pointerEvents="",e){e(c);return}this.pins=[c],this.mode="composing",this.render()},o}composer(){var re,ie,se;let e=document.createElement("div");e.className="panel";let t=Pe(this.pins),o=this.capture();e.innerHTML=`
|
|
17
17
|
<div class="panel__head" id="head">
|
|
18
18
|
<span class="panel__grip" aria-hidden="true">\u283F</span>
|
|
19
19
|
<div class="panel__heading">
|
|
20
|
-
<div class="panel__anchor">${
|
|
20
|
+
<div class="panel__anchor">${N(t)}</div>
|
|
21
21
|
<div class="panel__title">Report a problem</div>
|
|
22
22
|
</div>
|
|
23
23
|
<button id="close" class="panel__close" aria-label="Close">×</button>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<span class="panel__note">Sends this page's contents, your browser, and recent errors.</span>
|
|
61
61
|
<button id="cancel" class="ghost">Cancel</button>
|
|
62
62
|
<button id="send" class="primary">Send</button>
|
|
63
|
-
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,m)=>{var E;let g=document.createElement("div");g.className=u.error?"file file--bad":"file",g.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let v=document.createElement("span");v.className="file__name",v.textContent=(E=u.error)!=null?E:u.filename,g.appendChild(v);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{
|
|
63
|
+
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,m)=>{var E;let g=document.createElement("div");g.className=u.error?"file file--bad":"file",g.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let v=document.createElement("span");v.className="file__name",v.textContent=(E=u.error)!=null?E:u.filename,g.appendChild(v);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{B([u]),r.splice(m,1),c()},g.appendChild(x),i.appendChild(g)}),s.style.display=r.length>=5?"none":""},l=u=>{r.push(...Le(u,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",u=>{let m=_e(u);m.length>0&&(u.preventDefault(),l(m))}),s.addEventListener("dragover",u=>{u.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",u=>{var m,g;u.preventDefault(),s.classList.remove("drop--over"),l(Array.from((g=(m=u.dataTransfer)==null?void 0:m.files)!=null?g:[]))});let p="bug";e.querySelectorAll(".kind").forEach(u=>{u.onclick=()=>{var m;p=(m=u.dataset.kind)!=null?m:"bug",e.querySelectorAll(".kind").forEach(g=>g.classList.remove("kind--on")),u.classList.add("kind--on")}});let h=e.querySelector("#pins"),d=e.querySelector(".panel__anchor"),f=()=>{var u;if(d.textContent=Pe(this.pins),h.innerHTML="",this.pins.length>1&&this.pins.forEach((m,g)=>{var ae;let v=document.createElement("div");v.className="pin";let x=document.createElement("span");x.className="pin__n",x.textContent=String(g+1),v.appendChild(x);let E=document.createElement("span");E.className="pin__label",E.textContent=Be(m.anchor),E.title=(ae=m.anchor.page)!=null?ae:"",v.appendChild(E);let M=document.createElement("button");M.className="link",M.textContent="\xD7",M.setAttribute("aria-label",`Remove pin ${g+1}`),M.onclick=()=>{this.pins.splice(g,1),f()},v.appendChild(M),h.appendChild(v)}),this.pins.length<At){let m=document.createElement("button");m.className="link pins__add",m.id="add-pin",m.textContent=this.pins.length>0?"+ Add another pin":"+ Pin something on the page",m.onclick=()=>this.pickAnother(e,f),h.appendChild(m)}(u=this.redrawMarks)==null||u.call(this)};f();let w=e.querySelector("#message"),y=e.querySelector("#email"),A=(se=(re=this.reporter)==null?void 0:re.email)!=null?se:(ie=this.options.reporter)==null?void 0:ie.email;A&&!y.value&&(y.value=A);let q=e.querySelector("#shot"),U=e.querySelector("#status"),z=e.querySelector("#send"),ne=()=>{B(r),this.mode="idle",this.pins=[],this.dragged=null,this.render()};e.querySelector("#cancel").onclick=ne,e.querySelector("#close").onclick=ne;let oe=async()=>{var u;if(!w.value.trim()){U.textContent="Say what happened first.";return}z.disabled=!0,U.textContent="Sending\u2026";try{let m=await this.onSubmit({message:w.value.trim(),kind:p,email:y.value.trim()||void 0,anchors:this.pins.map(g=>g.anchor),withScreenshot:(u=q==null?void 0:q.checked)!=null?u:!1,files:r.filter(g=>!g.error)});this.reference=m.reference,this.uploadsFailed=m.uploadsFailed,B(r),this.mode="sent",this.pins=[],this.render()}catch(m){z.disabled=!1,U.textContent=m instanceof Error?`${m.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return z.onclick=oe,w.onkeydown=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&oe()},setTimeout(()=>w.focus(),0),this.contain(e),this.movable(e,e.querySelector("#head")),e}contain(e){for(let t of["pointerdown","mousedown","click"])e.addEventListener(t,o=>o.stopPropagation())}};async function Tt(n){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(n),!0}catch{}let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0",document.body.appendChild(e);try{return e.select(),document.execCommand("copy")}catch{return!1}finally{e.remove()}}var b=16,k=3,$e=["focus","focusin","mousedown","touchstart","click"],St=5,Fe="daybook-feedback:launcher";function Lt(){var n;try{let e=JSON.parse((n=localStorage.getItem(Fe))!=null?n:"null");if(e&&(e.h==="left"||e.h==="right")&&(e.v==="top"||e.v==="bottom")&&Number.isFinite(e.dx)&&Number.isFinite(e.dy))return{h:e.h,v:e.v,dx:e.dx,dy:e.dy}}catch{}return null}function _t(n){try{localStorage.setItem(Fe,JSON.stringify(n))}catch{}}function Ce(n,e,t,o){let r=_(e.dx,b,Math.max(b,window.innerWidth-t-b)),i=_(e.dy,b,Math.max(b,window.innerHeight-o-b));n.style.left=e.h==="left"?`${r}px`:"auto",n.style.right=e.h==="right"?`${r}px`:"auto",n.style.top=e.v==="top"?`${i}px`:"auto",n.style.bottom=e.v==="bottom"?`${i}px`:"auto"}var At=10;function Re(){return location.pathname+location.search}function Mt(n,e){let t=F(n,e),o=document.elementFromPoint(n,e),r=o&&o!==document.body&&o!==document.documentElement?o:null,i=r==null?void 0:r.getBoundingClientRect(),s=i&&i.width>=1&&i.height>=1?{left:i.left+window.scrollX,top:i.top+window.scrollY,width:i.width,height:i.height}:{left:n-12+window.scrollX,top:e-12+window.scrollY,width:24,height:24};return{anchor:t,element:r,box:s}}function Be(n){return n.elementText?`\u201C${n.elementText}\u201D`:n.selector&&n.selector!=="body"?n.selector:"a spot on the page"}function Pe(n){if(n.length===0)return"on this page";let[e]=n;if(!e)return"on this page";let t=`on ${Be(e.anchor)}`;return n.length===1?t:`${t} and ${n.length-1} more`}var te=56;function He(n){let e={left:n.left,right:window.innerWidth-n.right,top:n.top,bottom:window.innerHeight-n.bottom},t=Object.keys(e).reduce((i,s)=>e[s]<e[i]?s:i),o=t==="left"||t==="right"?t:e.left<=e.right?"left":"right",r=t==="top"||t==="bottom"?t:e.top<=e.bottom?"top":"bottom";return{h:o,v:r,dx:t===o?b:Math.max(b,Math.round(e[o])),dy:t===r?b:Math.max(b,Math.round(e[r]))}}function _(n,e,t){return Math.min(Math.max(n,e),t)}function N(n){return n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function $t(n){return typeof n=="string"&&/^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(n.trim())}var Ie='<svg class="launcher__icon" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M2 6.2C2 4.4 3.4 3 5.2 3h5.6C12.6 3 14 4.4 14 6.2v2.6c0 1.8-1.4 3.2-3.2 3.2H7l-3 2.4v-2.5A3.2 3.2 0 0 1 2 8.8V6.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>';function Ne(n){var o;let e=[];$t(n.accent)&&e.push(`--pm-accent: ${n.accent}`);let t={none:"0",sm:"6px",md:"12px",lg:"18px"}[(o=n.cornerRadius)!=null?o:"md"];return t&&e.push(`--pm-radius: ${t}`),n.colorScheme==="dark"?e.push(ze):n.colorScheme==="light"&&e.push(Ue),e.length>0?`:host { ${e.join("; ")} }`:""}var Oe=n=>Ct.includes(n.buttonStyle)?n.buttonStyle:"pill";function je(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Ie,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Ie}<span>${N(e)}</span>`:t.textContent=e,t}function qe(n,e={}){var i;let t=(i=n.shadowRoot)!=null?i:n.attachShadow({mode:"open"}),o=typeof e.launcherLabel=="string"&&e.launcherLabel.length>0?e.launcherLabel.slice(0,24):"Feedback";t.innerHTML=`<style>${De}</style><style>${Ne(e)}</style>`;let r=je(Oe(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var Ct=["pill","pill-icon","icon","text","outline"],Ue="--pm-surface: #fff; --pm-ink: #171717; --pm-muted: #525252; --pm-faint: #a3a3a3; --pm-line: #e5e5e5; --pm-line-strong: #d4d4d4; --pm-sunken: #f5f5f5; --pm-kbd: #404040; --pm-warn: #b45309; --pm-good: #047857; --pm-good-bg: #ecfdf5; --pm-good-line: #a7f3d0; --pm-accent: #171717; --pm-on-accent: #fafafa;",ze="--pm-surface: #1c1c1c; --pm-ink: #fafafa; --pm-muted: #a3a3a3; --pm-faint: #737373; --pm-line: #333; --pm-line-strong: #454545; --pm-sunken: #262626; --pm-kbd: #d4d4d4; --pm-warn: #fbbf24; --pm-good: #34d399; --pm-good-bg: #05271f; --pm-good-line: #065f46; --pm-accent: #fafafa; --pm-on-accent: #171717;",De=`
|
|
64
64
|
/*
|
|
65
65
|
Every colour in this file is one of these, and there are two sets of them.
|
|
66
66
|
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
:host {
|
|
83
83
|
all: initial;
|
|
84
84
|
|
|
85
|
-
${
|
|
85
|
+
${Ue}
|
|
86
86
|
|
|
87
87
|
--pm-radius: 12px;
|
|
88
88
|
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
@media (prefers-color-scheme: dark) {
|
|
98
|
-
:host { ${
|
|
98
|
+
:host { ${ze} }
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
|
|
@@ -112,6 +112,9 @@
|
|
|
112
112
|
background: var(--pm-accent); color: var(--pm-on-accent); font-size: 13px; font-weight: 500;
|
|
113
113
|
box-shadow: 0 2px 12px rgba(0,0,0,.3);
|
|
114
114
|
}
|
|
115
|
+
/* Dragged to move (PM-B-0121); touch-action:none or a touch drag is claimed by page scrolling. */
|
|
116
|
+
.launcher { touch-action: none; user-select: none }
|
|
117
|
+
.launcher--dragging { transition: none; cursor: grabbing; box-shadow: 0 8px 24px rgba(0,0,0,.35) }
|
|
115
118
|
.launcher:hover { filter: brightness(1.15) }
|
|
116
119
|
.launcher--pending { cursor: default; opacity: .85 }
|
|
117
120
|
.launcher--pending:hover { filter: none }
|
|
@@ -337,4 +340,4 @@ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset:
|
|
|
337
340
|
.file__icon { width: 28px; text-align: center }
|
|
338
341
|
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
|
339
342
|
.link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
|
|
340
|
-
`;var
|
|
343
|
+
`;var Ke="https://api.daybook.team",j=class{constructor(e){this.options=e;this.widget=null;this.started=!1;this.inFlight=null;this.epoch=0;this.ready=null;this.stopped=!1;var t;if(!e.ingestKey)throw new Error("ingestKey is required");this.client=new H((t=e.apiUrl)!=null?t:Ke,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new R(40,e.redact!==!1)}start(){var e;return this.stopped=!1,(e=this.trail)==null||e.start(),this.mount(),this.started||(this.started=!0,this.client.flush()),this.handshake(),this}mount(){this.widget||this.stopped||(this.widget=new O(this.options,e=>this.submit(e)),this.widget.setReporter(this.options.reporter),this.widget.mount())}handshake(){var o,r,i;let e=JSON.stringify([(o=this.options.reporter)!=null?o:null,(r=this.options.signature)!=null?r:null,this.epoch]);if(((i=this.inFlight)==null?void 0:i.key)===e)return this.inFlight.promise;let t=this.runHandshake().finally(()=>{var s;((s=this.inFlight)==null?void 0:s.promise)===t&&(this.inFlight=null)});return this.inFlight={key:e,promise:t},t}async runHandshake(){var e,t,o,r,i,s,a;try{let c=await this.client.handshake({identity:this.options.reporter,signature:this.options.signature,locale:typeof navigator!="undefined"?navigator.language:void 0,sdk:{name:"js",version:S}});if(this.ready=c,(t=(e=this.options).onReady)==null||t.call(e,c),c.reporterStatus==="Blocked"){(o=this.widget)==null||o.unmount(),this.widget=null;return}this.mount();let l=this.widget;if(!l)return;l.setTheme(Ht(c.theme)),l.setPolicy((r=c.policy)!=null?r:null),l.setState(c.reporterStatus==="Pending"?"pending":"ready")}catch(c){(s=(i=this.options).onError)==null||s.call(i,c),console.warn("[feedback] handshake failed; the widget will not appear",c),(a=this.widget)==null||a.unmount(),this.widget=null}}identify(e){var t;this.options={...this.options,reporter:e?{...this.options.reporter,...e}:void 0},(t=this.widget)==null||t.setReporter(this.options.reporter),this.widget&&this.handshake()}async signIn(){await this.client.signIn(),this.epoch++,await this.handshake()}authenticate(e){this.options={...this.options,signature:e!=null?e:void 0},this.widget&&this.handshake()}stop(){var e,t;this.started=!1,this.stopped=!0,(e=this.trail)==null||e.stop(),(t=this.widget)==null||t.unmount(),this.widget=null}open(){var e;(e=this.widget)==null||e.open()}async report(e,t={}){var o,r,i;return this.client.send({message:e,surface:this.options.surface,...t,context:{...J({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var a,c,l,p,h;let t=e.withScreenshot?await be(this.options.redact!==!1,()=>{var d,f;return(f=(d=this.widget)==null?void 0:d.conceal())!=null?f:(()=>{})}):null,o=this.options.dom===!1?null:Ee(e.anchors,this.options.redact!==!1),r=[...e.files,...t?[t]:[],...o?[Rt(o)]:[]],i={message:e.message,kind:e.kind,app:this.options.app,surface:this.options.surface,reporter:e.email?{...this.options.reporter,email:e.email}:this.options.reporter,context:J({anchors:e.anchors,breadcrumbs:(a=this.trail)==null?void 0:a.list(),app:this.options.app})},s=[];try{let d=await this.client.send(i,r,(f,w)=>{var y,A;s.push(w),console.warn(`[feedback] "${f.filename}" did not upload`,w),(A=(y=this.options).onError)==null||A.call(y,w)});return d.uploadsFailed=s.length,(l=(c=this.options).onSent)==null||l.call(c,d),{reference:d.reference,uploadsFailed:s.length}}catch(d){throw this.client.queue(i),(h=(p=this.options).onError)==null||h.call(p,d),d}}};function Rt(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function Pt(n){return new j(n).start()}function Ht(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return Ge(It);})();
|
package/dist/index.js
CHANGED
|
@@ -142,12 +142,19 @@ export class DaybookFeedback {
|
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
this.mount();
|
|
145
|
-
|
|
145
|
+
// mount() declines once the host has stopped the widget, and stop() can land while the
|
|
146
|
+
// handshake is in flight. Asserting a widget here threw "Cannot read properties of null
|
|
147
|
+
// (reading 'setTheme')", which the catch below then reported to the host as a failed
|
|
148
|
+
// handshake — for a widget that had been taken away on purpose.
|
|
149
|
+
const widget = this.widget;
|
|
150
|
+
if (!widget)
|
|
151
|
+
return;
|
|
152
|
+
widget.setTheme(parseTheme(result.theme));
|
|
146
153
|
// What the integration allows, so the composer offers only controls that can act. Served
|
|
147
154
|
// since the handshake existed and never read until now — which is why an integration with
|
|
148
155
|
// screenshots turned off still showed a tick box for them.
|
|
149
|
-
|
|
150
|
-
|
|
156
|
+
widget.setPolicy(result.policy ?? null);
|
|
157
|
+
widget.setState(result.reporterStatus === 'Pending' ? 'pending' : 'ready');
|
|
151
158
|
}
|
|
152
159
|
catch (error) {
|
|
153
160
|
// Told to the host as well as the console. In the Daybook sign-in mode the widget is *meant*
|
package/dist/version.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* npm build is plain tsc and has no bundler to inline it; test/version.test.js and publish-sdk.sh
|
|
7
7
|
* both refuse a build where this and package.json disagree.
|
|
8
8
|
*/
|
|
9
|
-
export declare const SDK_VERSION = "1.4.
|
|
9
|
+
export declare const SDK_VERSION = "1.4.3";
|
|
10
10
|
export declare const SDK_NAME = "js";
|
package/dist/version.js
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* npm build is plain tsc and has no bundler to inline it; test/version.test.js and publish-sdk.sh
|
|
7
7
|
* both refuse a build where this and package.json disagree.
|
|
8
8
|
*/
|
|
9
|
-
export const SDK_VERSION = '1.4.
|
|
9
|
+
export const SDK_VERSION = '1.4.3';
|
|
10
10
|
export const SDK_NAME = 'js';
|
package/dist/widget.d.ts
CHANGED
|
@@ -88,6 +88,30 @@ export declare class FeedbackWidget {
|
|
|
88
88
|
*/
|
|
89
89
|
private state;
|
|
90
90
|
setState(state: 'ready' | 'pending'): void;
|
|
91
|
+
/**
|
|
92
|
+
* Keeps the host page's focus traps off our fields. PM-B-0120.
|
|
93
|
+
*
|
|
94
|
+
* A host modal holds focus inside itself, and our composer is outside it — in a shadow root at the
|
|
95
|
+
* end of body — so the trap reads every focus on our textarea as focus escaping and takes it back.
|
|
96
|
+
* The reporter clicks the field and cannot type. Naive UI does it on `focus` (vueuc's FocusTrap,
|
|
97
|
+
* resetting to the modal's first field); the focus-trap library on `focusin`, and it also
|
|
98
|
+
* prevents the default of `mousedown` and `touchstart`, so the click never focuses anything at all.
|
|
99
|
+
*
|
|
100
|
+
* All of them listen on the document in the capture phase, which runs before anything inside our
|
|
101
|
+
* shadow root — so contain(), which stops events on the way back up, is too late. The window's
|
|
102
|
+
* capture phase is the one place earlier than the document's. An event from inside our host is
|
|
103
|
+
* stopped there, and the trap never hears of it. Focus is not cancelable: the field keeps it.
|
|
104
|
+
*
|
|
105
|
+
* focus-trap also swallows every `click` outside its modal — preventDefault and
|
|
106
|
+
* stopImmediatePropagation — which left the launcher and Send dead under one. A click stopped at
|
|
107
|
+
* the window never reaches our handlers either, so a copy is dispatched on its own target inside
|
|
108
|
+
* the shadow root, not composed, to run them without the page seeing it. The copy is cancelled
|
|
109
|
+
* before it goes: the original still does the native part — ticks the checkbox, follows the label,
|
|
110
|
+
* opens the file picker, all as a trusted click — and two un-cancelled clicks would tick a box and
|
|
111
|
+
* untick it again. A `focusin` is dispatched again the same way, for the confirmation that holds
|
|
112
|
+
* itself open while it is in focus. Neither copy can leave the shadow root, so neither comes back.
|
|
113
|
+
*/
|
|
114
|
+
private shield;
|
|
91
115
|
mount(): void;
|
|
92
116
|
unmount(): void;
|
|
93
117
|
open(): void;
|
|
@@ -199,6 +223,30 @@ export declare class FeedbackWidget {
|
|
|
199
223
|
private movable;
|
|
200
224
|
/** Applies the drag, if there is one, or hands the panel back to its home corner. */
|
|
201
225
|
private place;
|
|
226
|
+
/**
|
|
227
|
+
* Where the reporter dragged the launcher, if they did. PM-B-0121.
|
|
228
|
+
*
|
|
229
|
+
* The clearance probe dodges small floating buttons, and deliberately not a host modal: its box is
|
|
230
|
+
* scenery, and a Save button in its footer is not fixed at all, so nothing tells the probe it is
|
|
231
|
+
* there. The reporter can see it, so they move the launcher off it.
|
|
232
|
+
*
|
|
233
|
+
* Remembered, unlike the panel's drag (see dragged). The panel is up for one report; the launcher
|
|
234
|
+
* is on every screen, and one moved off a Save button that comes back to the same spot on the next
|
|
235
|
+
* page load has been moved for nothing. The Flutter SDK remembers its button the same way.
|
|
236
|
+
*/
|
|
237
|
+
private launcherAt;
|
|
238
|
+
/** Set by a drag, so the click the browser fires when the press ends does not also open the picker. */
|
|
239
|
+
private swallowClick;
|
|
240
|
+
/** Draws the launcher where it was dragged, or leaves it to the corner the stylesheet gives it. */
|
|
241
|
+
private placeLauncher;
|
|
242
|
+
/** Keeps a dragged launcher on screen when the window changes size. */
|
|
243
|
+
private watchLauncher;
|
|
244
|
+
/**
|
|
245
|
+
* Press and drag the launcher anywhere; let go and it goes flush to the nearest edge.
|
|
246
|
+
*
|
|
247
|
+
* A press that travels less than DRAG_SLOP is a click, so a shaky hand still opens the picker.
|
|
248
|
+
*/
|
|
249
|
+
private movableLauncher;
|
|
202
250
|
private render;
|
|
203
251
|
/**
|
|
204
252
|
* Shown in place of the launcher when this person is waiting on approval.
|
package/dist/widget.js
CHANGED
|
@@ -59,6 +59,20 @@ export class FeedbackWidget {
|
|
|
59
59
|
* report opens where the install said it would.
|
|
60
60
|
*/
|
|
61
61
|
this.dragged = null;
|
|
62
|
+
/**
|
|
63
|
+
* Where the reporter dragged the launcher, if they did. PM-B-0121.
|
|
64
|
+
*
|
|
65
|
+
* The clearance probe dodges small floating buttons, and deliberately not a host modal: its box is
|
|
66
|
+
* scenery, and a Save button in its footer is not fixed at all, so nothing tells the probe it is
|
|
67
|
+
* there. The reporter can see it, so they move the launcher off it.
|
|
68
|
+
*
|
|
69
|
+
* Remembered, unlike the panel's drag (see dragged). The panel is up for one report; the launcher
|
|
70
|
+
* is on every screen, and one moved off a Save button that comes back to the same spot on the next
|
|
71
|
+
* page load has been moved for nothing. The Flutter SDK remembers its button the same way.
|
|
72
|
+
*/
|
|
73
|
+
this.launcherAt = readLauncherAt();
|
|
74
|
+
/** Set by a drag, so the click the browser fires when the press ends does not also open the picker. */
|
|
75
|
+
this.swallowClick = false;
|
|
62
76
|
/** The reference of the last report, so the confirmation can quote it. */
|
|
63
77
|
this.reference = null;
|
|
64
78
|
/** How many attachments did not land, so the confirmation can be honest about it. */
|
|
@@ -162,6 +176,9 @@ export class FeedbackWidget {
|
|
|
162
176
|
queued = false;
|
|
163
177
|
if (this.mode !== 'idle')
|
|
164
178
|
return;
|
|
179
|
+
// Where the reporter put it outranks where we would dodge to.
|
|
180
|
+
if (this.launcherAt)
|
|
181
|
+
return;
|
|
165
182
|
try {
|
|
166
183
|
const next = measureClearance(this.homeSlot(), this.host);
|
|
167
184
|
// A pixel or two of churn is measurement noise, and acting on it makes the launcher shiver.
|
|
@@ -212,11 +229,81 @@ export class FeedbackWidget {
|
|
|
212
229
|
if (this.host.isConnected)
|
|
213
230
|
this.render();
|
|
214
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Keeps the host page's focus traps off our fields. PM-B-0120.
|
|
234
|
+
*
|
|
235
|
+
* A host modal holds focus inside itself, and our composer is outside it — in a shadow root at the
|
|
236
|
+
* end of body — so the trap reads every focus on our textarea as focus escaping and takes it back.
|
|
237
|
+
* The reporter clicks the field and cannot type. Naive UI does it on `focus` (vueuc's FocusTrap,
|
|
238
|
+
* resetting to the modal's first field); the focus-trap library on `focusin`, and it also
|
|
239
|
+
* prevents the default of `mousedown` and `touchstart`, so the click never focuses anything at all.
|
|
240
|
+
*
|
|
241
|
+
* All of them listen on the document in the capture phase, which runs before anything inside our
|
|
242
|
+
* shadow root — so contain(), which stops events on the way back up, is too late. The window's
|
|
243
|
+
* capture phase is the one place earlier than the document's. An event from inside our host is
|
|
244
|
+
* stopped there, and the trap never hears of it. Focus is not cancelable: the field keeps it.
|
|
245
|
+
*
|
|
246
|
+
* focus-trap also swallows every `click` outside its modal — preventDefault and
|
|
247
|
+
* stopImmediatePropagation — which left the launcher and Send dead under one. A click stopped at
|
|
248
|
+
* the window never reaches our handlers either, so a copy is dispatched on its own target inside
|
|
249
|
+
* the shadow root, not composed, to run them without the page seeing it. The copy is cancelled
|
|
250
|
+
* before it goes: the original still does the native part — ticks the checkbox, follows the label,
|
|
251
|
+
* opens the file picker, all as a trusted click — and two un-cancelled clicks would tick a box and
|
|
252
|
+
* untick it again. A `focusin` is dispatched again the same way, for the confirmation that holds
|
|
253
|
+
* itself open while it is in focus. Neither copy can leave the shadow root, so neither comes back.
|
|
254
|
+
*/
|
|
255
|
+
shield() {
|
|
256
|
+
const guard = (event) => {
|
|
257
|
+
const path = event.composedPath();
|
|
258
|
+
if (!path.includes(this.host))
|
|
259
|
+
return;
|
|
260
|
+
event.stopImmediatePropagation();
|
|
261
|
+
const [target] = path;
|
|
262
|
+
if (!(target instanceof Node) || target === this.host)
|
|
263
|
+
return;
|
|
264
|
+
if (event.type === 'focusin') {
|
|
265
|
+
target.dispatchEvent(new FocusEvent('focusin', { bubbles: true, composed: false }));
|
|
266
|
+
}
|
|
267
|
+
else if (event.type === 'click' && event instanceof MouseEvent) {
|
|
268
|
+
const copy = new MouseEvent('click', {
|
|
269
|
+
bubbles: true,
|
|
270
|
+
cancelable: true,
|
|
271
|
+
composed: false,
|
|
272
|
+
detail: event.detail,
|
|
273
|
+
screenX: event.screenX,
|
|
274
|
+
screenY: event.screenY,
|
|
275
|
+
clientX: event.clientX,
|
|
276
|
+
clientY: event.clientY,
|
|
277
|
+
button: event.button,
|
|
278
|
+
buttons: event.buttons,
|
|
279
|
+
ctrlKey: event.ctrlKey,
|
|
280
|
+
shiftKey: event.shiftKey,
|
|
281
|
+
altKey: event.altKey,
|
|
282
|
+
metaKey: event.metaKey,
|
|
283
|
+
});
|
|
284
|
+
copy.preventDefault();
|
|
285
|
+
target.dispatchEvent(copy);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
for (const type of SHIELDED)
|
|
289
|
+
window.addEventListener(type, guard, true);
|
|
290
|
+
this.detach.push(() => {
|
|
291
|
+
for (const type of SHIELDED)
|
|
292
|
+
window.removeEventListener(type, guard, true);
|
|
293
|
+
});
|
|
294
|
+
// Keys stop at our shadow root, on the way up. Typing in the composer is typing to us: the host's
|
|
295
|
+
// shortcuts see a key whose target is our host element, not a field, so their own "is somebody
|
|
296
|
+
// typing" check passes — and its Escape closes the host modal under the report being written.
|
|
297
|
+
const keep = (event) => event.stopPropagation();
|
|
298
|
+
for (const type of ['keydown', 'keyup', 'keypress'])
|
|
299
|
+
this.root.addEventListener(type, keep);
|
|
300
|
+
}
|
|
215
301
|
mount() {
|
|
216
302
|
document.body.appendChild(this.host);
|
|
217
303
|
this.applyPlacement();
|
|
218
304
|
this.render();
|
|
219
305
|
this.watchClearance();
|
|
306
|
+
this.watchLauncher();
|
|
220
307
|
if (this.options.hotkey !== null) {
|
|
221
308
|
const hotkey = (this.options.hotkey ?? 'f').toLowerCase();
|
|
222
309
|
const onKey = (event) => {
|
|
@@ -257,7 +344,10 @@ export class FeedbackWidget {
|
|
|
257
344
|
};
|
|
258
345
|
window.addEventListener('keydown', onKey);
|
|
259
346
|
this.detach.push(() => window.removeEventListener('keydown', onKey));
|
|
347
|
+
// Keys from inside the widget stop at the shadow root (see shield), so they are heard there.
|
|
348
|
+
this.root.addEventListener('keydown', onKey);
|
|
260
349
|
}
|
|
350
|
+
this.shield();
|
|
261
351
|
}
|
|
262
352
|
unmount() {
|
|
263
353
|
for (const undo of this.detach.splice(0))
|
|
@@ -524,14 +614,71 @@ export class FeedbackWidget {
|
|
|
524
614
|
}
|
|
525
615
|
// Re-clamped on every render rather than only on drop: the window the panel was placed in is
|
|
526
616
|
// not necessarily the window it is being drawn in.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
617
|
+
putAt(panel, at, panel.offsetWidth || 380, panel.offsetHeight || 240);
|
|
618
|
+
}
|
|
619
|
+
/** Draws the launcher where it was dragged, or leaves it to the corner the stylesheet gives it. */
|
|
620
|
+
placeLauncher(button) {
|
|
621
|
+
if (!this.launcherAt) {
|
|
622
|
+
button.style.left = button.style.right = button.style.top = button.style.bottom = '';
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
putAt(button, this.launcherAt, button.offsetWidth || 120, button.offsetHeight || 36);
|
|
626
|
+
}
|
|
627
|
+
/** Keeps a dragged launcher on screen when the window changes size. */
|
|
628
|
+
watchLauncher() {
|
|
629
|
+
const onResize = () => {
|
|
630
|
+
const button = this.root.querySelector('.launcher');
|
|
631
|
+
if (button && this.mode === 'idle' && this.state === 'ready')
|
|
632
|
+
this.placeLauncher(button);
|
|
633
|
+
};
|
|
634
|
+
window.addEventListener('resize', onResize);
|
|
635
|
+
this.detach.push(() => window.removeEventListener('resize', onResize));
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Press and drag the launcher anywhere; let go and it goes flush to the nearest edge.
|
|
639
|
+
*
|
|
640
|
+
* A press that travels less than DRAG_SLOP is a click, so a shaky hand still opens the picker.
|
|
641
|
+
*/
|
|
642
|
+
movableLauncher(button) {
|
|
643
|
+
button.addEventListener('pointerdown', (event) => {
|
|
644
|
+
this.swallowClick = false;
|
|
645
|
+
if (event.button !== 0)
|
|
646
|
+
return;
|
|
647
|
+
const rect = button.getBoundingClientRect();
|
|
648
|
+
const grabX = event.clientX - rect.left;
|
|
649
|
+
const grabY = event.clientY - rect.top;
|
|
650
|
+
let dragging = false;
|
|
651
|
+
button.setPointerCapture(event.pointerId);
|
|
652
|
+
const move = (moved) => {
|
|
653
|
+
if (!dragging) {
|
|
654
|
+
if (Math.hypot(moved.clientX - event.clientX, moved.clientY - event.clientY) < DRAG_SLOP)
|
|
655
|
+
return;
|
|
656
|
+
dragging = true;
|
|
657
|
+
button.classList.add('launcher--dragging');
|
|
658
|
+
}
|
|
659
|
+
button.style.left = `${clamp(moved.clientX - grabX, 0, window.innerWidth - rect.width)}px`;
|
|
660
|
+
button.style.top = `${clamp(moved.clientY - grabY, 0, window.innerHeight - rect.height)}px`;
|
|
661
|
+
button.style.right = 'auto';
|
|
662
|
+
button.style.bottom = 'auto';
|
|
663
|
+
};
|
|
664
|
+
const drop = () => {
|
|
665
|
+
if (button.hasPointerCapture(event.pointerId))
|
|
666
|
+
button.releasePointerCapture(event.pointerId);
|
|
667
|
+
button.removeEventListener('pointermove', move);
|
|
668
|
+
button.removeEventListener('pointerup', drop);
|
|
669
|
+
button.removeEventListener('pointercancel', drop);
|
|
670
|
+
if (!dragging)
|
|
671
|
+
return;
|
|
672
|
+
button.classList.remove('launcher--dragging');
|
|
673
|
+
this.launcherAt = stickToFrame(button.getBoundingClientRect());
|
|
674
|
+
saveLauncherAt(this.launcherAt);
|
|
675
|
+
this.placeLauncher(button);
|
|
676
|
+
this.swallowClick = true;
|
|
677
|
+
};
|
|
678
|
+
button.addEventListener('pointermove', move);
|
|
679
|
+
button.addEventListener('pointerup', drop);
|
|
680
|
+
button.addEventListener('pointercancel', drop);
|
|
681
|
+
});
|
|
535
682
|
}
|
|
536
683
|
render() {
|
|
537
684
|
const layer = this.root.getElementById('layer');
|
|
@@ -539,7 +686,14 @@ export class FeedbackWidget {
|
|
|
539
686
|
this.cancelAdding = null;
|
|
540
687
|
layer.innerHTML = '';
|
|
541
688
|
if (this.mode === 'idle') {
|
|
542
|
-
|
|
689
|
+
if (this.state === 'pending') {
|
|
690
|
+
layer.appendChild(this.pending());
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
// Placed once it is in the document, because placing needs its size.
|
|
694
|
+
const button = this.launcher();
|
|
695
|
+
layer.appendChild(button);
|
|
696
|
+
this.placeLauncher(button);
|
|
543
697
|
return;
|
|
544
698
|
}
|
|
545
699
|
if (this.mode === 'sent') {
|
|
@@ -651,10 +805,18 @@ export class FeedbackWidget {
|
|
|
651
805
|
}
|
|
652
806
|
launcher() {
|
|
653
807
|
const button = launcherButton(this.buttonStyle, this.launcherLabel ?? 'Feedback');
|
|
654
|
-
button.title = this.options.hotkey === null
|
|
808
|
+
button.title = (this.options.hotkey === null
|
|
655
809
|
? 'Report a problem'
|
|
656
|
-
: `Report a problem (${(this.options.hotkey ?? 'f').toUpperCase()})
|
|
657
|
-
button.onclick = () => {
|
|
810
|
+
: `Report a problem (${(this.options.hotkey ?? 'f').toUpperCase()})`) + ' · drag to move';
|
|
811
|
+
button.onclick = () => {
|
|
812
|
+
if (this.swallowClick) {
|
|
813
|
+
this.swallowClick = false;
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
this.mode = 'picking';
|
|
817
|
+
this.render();
|
|
818
|
+
};
|
|
819
|
+
this.movableLauncher(button);
|
|
658
820
|
return button;
|
|
659
821
|
}
|
|
660
822
|
/**
|
|
@@ -1022,6 +1184,52 @@ export async function copyText(text) {
|
|
|
1022
1184
|
const EDGE = 16;
|
|
1023
1185
|
/** How far the ring sits outside the element it marks, so it frames rather than covers. */
|
|
1024
1186
|
const RING_PAD = 3;
|
|
1187
|
+
/**
|
|
1188
|
+
* What a host page's focus trap listens to, and so what never leaves the widget. PM-B-0120.
|
|
1189
|
+
*
|
|
1190
|
+
* Not the pointer events: the panel and launcher drags run on them, an event stopped at the window
|
|
1191
|
+
* never reaches them, and no trap listens to them. `click` is here, and dispatched again inside.
|
|
1192
|
+
*/
|
|
1193
|
+
const SHIELDED = ['focus', 'focusin', 'mousedown', 'touchstart', 'click'];
|
|
1194
|
+
/** How far a press on the launcher moves before it is a drag rather than a click. */
|
|
1195
|
+
const DRAG_SLOP = 5;
|
|
1196
|
+
/** Where a dragged launcher is kept, per site. PM-B-0121. */
|
|
1197
|
+
const LAUNCHER_KEY = 'daybook-feedback:launcher';
|
|
1198
|
+
function readLauncherAt() {
|
|
1199
|
+
try {
|
|
1200
|
+
const at = JSON.parse(localStorage.getItem(LAUNCHER_KEY) ?? 'null');
|
|
1201
|
+
// Checked field by field: the value only ever reaches a style as a side's name and a number, and
|
|
1202
|
+
// anything else in storage is somebody else's, or an older shape.
|
|
1203
|
+
if (at && (at.h === 'left' || at.h === 'right') && (at.v === 'top' || at.v === 'bottom')
|
|
1204
|
+
&& Number.isFinite(at.dx) && Number.isFinite(at.dy)) {
|
|
1205
|
+
return { h: at.h, v: at.v, dx: at.dx, dy: at.dy };
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
catch {
|
|
1209
|
+
// Storage blocked or unreadable: the launcher starts at home, which is where it would be anyway.
|
|
1210
|
+
}
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
function saveLauncherAt(at) {
|
|
1214
|
+
try {
|
|
1215
|
+
localStorage.setItem(LAUNCHER_KEY, JSON.stringify(at));
|
|
1216
|
+
}
|
|
1217
|
+
catch {
|
|
1218
|
+
// Kept for this page view only.
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Puts an element at a placement, re-clamped to the window it is drawn in now rather than the one
|
|
1223
|
+
* it was placed in.
|
|
1224
|
+
*/
|
|
1225
|
+
function putAt(element, at, width, height) {
|
|
1226
|
+
const dx = clamp(at.dx, EDGE, Math.max(EDGE, window.innerWidth - width - EDGE));
|
|
1227
|
+
const dy = clamp(at.dy, EDGE, Math.max(EDGE, window.innerHeight - height - EDGE));
|
|
1228
|
+
element.style.left = at.h === 'left' ? `${dx}px` : 'auto';
|
|
1229
|
+
element.style.right = at.h === 'right' ? `${dx}px` : 'auto';
|
|
1230
|
+
element.style.top = at.v === 'top' ? `${dy}px` : 'auto';
|
|
1231
|
+
element.style.bottom = at.v === 'bottom' ? `${dy}px` : 'auto';
|
|
1232
|
+
}
|
|
1025
1233
|
/**
|
|
1026
1234
|
* How many pins one report may carry. Ten is more than any report has needed, and a limit keeps a
|
|
1027
1235
|
* slipped hand from filing a report whose picture is nothing but rings.
|
|
@@ -1265,6 +1473,9 @@ const STYLES = `
|
|
|
1265
1473
|
background: var(--pm-accent); color: var(--pm-on-accent); font-size: 13px; font-weight: 500;
|
|
1266
1474
|
box-shadow: 0 2px 12px rgba(0,0,0,.3);
|
|
1267
1475
|
}
|
|
1476
|
+
/* Dragged to move (PM-B-0121); touch-action:none or a touch drag is claimed by page scrolling. */
|
|
1477
|
+
.launcher { touch-action: none; user-select: none }
|
|
1478
|
+
.launcher--dragging { transition: none; cursor: grabbing; box-shadow: 0 8px 24px rgba(0,0,0,.35) }
|
|
1268
1479
|
.launcher:hover { filter: brightness(1.15) }
|
|
1269
1480
|
.launcher--pending { cursor: default; opacity: .85 }
|
|
1270
1481
|
.launcher--pending:hover { filter: none }
|
package/package.json
CHANGED