@daybook/feedback 1.4.3 → 1.6.0
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/README.md +122 -4
- package/dist/blur.d.ts +36 -0
- package/dist/blur.js +26 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.js +9 -2
- package/dist/context.d.ts +24 -0
- package/dist/context.js +17 -3
- package/dist/feedback.js +55 -12
- package/dist/index.d.ts +12 -0
- package/dist/index.js +32 -3
- package/dist/module.d.ts +23 -0
- package/dist/module.js +53 -0
- package/dist/redact.d.ts +4 -0
- package/dist/redact.js +8 -3
- package/dist/screenshot.d.ts +37 -7
- package/dist/screenshot.js +137 -11
- package/dist/secrets.d.ts +86 -0
- package/dist/secrets.js +237 -0
- package/dist/snapshot.d.ts +14 -2
- package/dist/snapshot.js +193 -38
- package/dist/types.d.ts +18 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/widget.d.ts +52 -2
- package/dist/widget.js +341 -22
- package/package.json +12 -5
package/dist/feedback.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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 */`:
|
|
3
|
-
--pm-${r}: ${
|
|
1
|
+
"use strict";var DaybookFeedback=(()=>{var ee=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(n,e)=>{for(var t in e)ee(n,t,{get:e[t],enumerable:!0})},mt=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pt(e))!ut.call(n,r)&&r!==t&&ee(n,r,{get:()=>e[r],enumerable:!(o=ht(e,r))||o.enumerable});return n};var gt=n=>mt(ee({},"__esModule",{value:!0}),n);var vn={};ft(vn,{DEFAULT_API_URL:()=>dt,DaybookFeedback:()=>O,SDK_VERSION:()=>I,captureAnchor:()=>Z,init:()=>yn,previewLauncher:()=>rt,resolveAnchor:()=>He});var I="1.6.0";var ve="key|token|secret|passw(?:or)?d|pwd|api|auth|credential|signature",ke=new RegExp(ve,"i"),bt=[{kind:"Daybook API key",pattern:/\bpmk_[0-9a-f]{16,}/gi},{kind:"Stripe key",pattern:/\b[sr]k_(?:live|test)_[A-Za-z0-9]{16,}/g},{kind:"secret key",pattern:/\bsk-[A-Za-z0-9_-]{20,}/g,accept:vt},{kind:"GitHub token",pattern:/\bgh[pousr]_[A-Za-z0-9]{20,}/g},{kind:"GitHub token",pattern:/\bgithub_pat_[A-Za-z0-9_]{22,}/g},{kind:"Slack token",pattern:/\bxox[baprs]-[A-Za-z0-9-]{10,}/g},{kind:"AWS access key",pattern:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{kind:"private key",pattern:/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g},{kind:"JWT",pattern:/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]*)?/g},{kind:"token",pattern:/\b(?:Bearer|Basic)\s+([A-Za-z0-9+/_.~-]{16,}=*)/gi,value:1,accept:n=>ye(n,16)},{kind:"secret",pattern:new RegExp(`(?:${ve})[A-Za-z0-9_.-]*["']?(?:\\s*(?:[:=]>?|\\s(?:is|was)\\s)\\s*|\\s+)["']?([A-Za-z0-9+/_.~-]{20,}=*)`,"gi"),value:1,accept:n=>ye(n,20)}],wt=/[A-Za-z0-9_+/=.~-]{15,}/,yt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xt=/^[0-9a-f]+$/i;function ye(n,e=20){var s;let t=n.replace(/=+$/,"");if(t.length<e||yt.test(t))return!1;if(xt.test(t))return t.length>=24&&/[0-9]/.test(t)&&/[a-f]/i.test(t);let o=t.replace(/[^A-Za-z0-9]/g,"");if(o.length<e-4||!/[a-z]/.test(o)||!/[A-Z]/.test(o)||!/[0-9]/.test(o)||((s=o.match(/[a-z]{3,}/g))!=null?s:[]).reduce((a,c)=>a+c.length,0)/o.length>=.5)return!1;let i=0;for(let a=1;a<o.length;a+=1)xe(o.charCodeAt(a))!==xe(o.charCodeAt(a-1))&&(i+=1);return i/(o.length-1)>=.35}function xe(n){return n>=48&&n<=57?0:n>=65&&n<=90?1:2}function vt(n){var e;return((e=n.match(/[A-Za-z0-9]{16,}/g))!=null?e:[]).some(t=>/[0-9]/.test(t)&&/[A-Za-z]/.test(t))}function H(n,e=""){let t=e+n;if(!wt.test(t))return[];let o=[];bt.forEach((i,s)=>{var a;i.pattern.lastIndex=0;for(let c=i.pattern.exec(t);c;c=i.pattern.exec(t)){let l=i.value&&(a=c[i.value])!=null?a:c[0],d=c.index+c[0].length,h=d-l.length;if(i.accept&&!i.accept(l)){i.pattern.lastIndex=c.index+1;continue}d>e.length&&o.push({start:Math.max(h,e.length)-e.length,end:d-e.length,kind:i.kind,rule:s})}}),o.sort((i,s)=>i.start-s.start||i.rule-s.rule);let r=[];for(let i of o){let s=r[r.length-1];s&&i.start<s.end?(s.end=Math.max(s.end,i.end),i.rule<s.rule&&(s.kind=i.kind,s.rule=i.rule)):r.push({...i})}return r.map(({start:i,end:s,kind:a})=>({start:i,end:s,kind:a}))}function A(n,e=""){let t=H(n,e);if(t.length===0)return{text:n,count:0};let o="",r=0;for(let i of t)o+=`${n.slice(r,i.start)}[masked: ${i.kind}]`,r=i.end;return{text:o+n.slice(r),count:t.length}}function N(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 kt=/pass|secret|token|auth|cvv|card|ssn|pin|otp|key/i;function Ee(n,e){return n.length===0?"":e&&kt.test(e)?"[redacted]":`[${n.length} chars]`}function te(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 te(l)}if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement){let l=(i=(r=n.getAttribute("name"))!=null?r:n.id)!=null?i:"",d=n instanceof HTMLInputElement?n.type:e;return`${e}[${d}]${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 _e(n){let e=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]");return A(e.slice(0,900)).text.slice(0,500)}var L="data-daybook-private";var D=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?_e(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",te(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",N(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(ne).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: ${ne(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} ${N(Se(t[0]))} ${i}ms`),r}catch(r){throw this.add("network",`failed ${N(Se(t[0]))}: ${ne(r)}`),r}},this.detach.push(()=>{window.fetch=e})}};function Se(n){return typeof n=="string"?n:n instanceof URL?n.href:n.url}function ne(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 re="pm.feedback.queue";var j=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,d;let r={idempotencyKey:(c=e.idempotencyKey)!=null?c:Ae(),...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 X(i);let s=await i.json(),a=((d=e.attachments)!=null?d:[]).length;return await Promise.all(t.map(async(h,f)=>{let p=Et(s,a+f);if(!p){o==null||o(h,new Error("The server would not accept that file."));return}try{await this.upload(p,h)}catch(m){o==null||o(h,m)}})),s}async flush(){let e=$e();if(e.length!==0){Le([]);for(let t of e)try{let o=await this.post("/ingest/v1",t);!o.ok&&(o.status===429||o.status>=500)&&oe(t)}catch{oe(t)}}}queue(e){var t;oe({...e,idempotencyKey:(t=e.idempotencyKey)!=null?t:Ae(),attachments:void 0})}async signIn(){let e=Te(64),t=await _t(e),o=Te(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,d)=>{let h=setInterval(()=>{i.closed&&(p(),d(Object.assign(new Error("Sign-in cancelled"),{code:"cancelled"})))},400),f=m=>{if(m.origin!==new URL(this.base()).origin)return;let g=m.data;if((g==null?void 0:g.source)==="daybook-feedback"&&g.state===o){if(p(),g.error||!g.code){d(Object.assign(new Error("Sign-in was refused"),{code:g.error||"refused"}));return}l(g.code)}},p=()=>{clearInterval(h),window.removeEventListener("message",f)};window.addEventListener("message",f)}),a=await this.post("/ingest/v1/token",{code:s,codeVerifier:e});if(!a.ok)throw await X(a);let{identityToken:c}=await a.json();return this.identityToken=c,c}keyHeader(){return this.ingestKey.startsWith("dbk_")?"X-Daybook-Key":"X-Ingest-Key"}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 X(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",[this.keyHeader()]: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,[this.keyHeader()]:this.ingestKey},body:t.blob,credentials:"omit"});if(!o.ok)throw await X(o);await this.post(`/ingest/v1/attachments/${e.id}/confirm`,{})}};function Et(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 oe(n){let e=$e();e.push(n),Le(e.slice(-20))}function $e(){try{let n=localStorage.getItem(re);return n?JSON.parse(n):[]}catch{return[]}}function Le(n){try{n.length===0?localStorage.removeItem(re):localStorage.setItem(re,JSON.stringify(n))}catch{}}async function X(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 Ae(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Te(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=new Uint8Array(n);return crypto.getRandomValues(t),Array.from(t,o=>e[o%e.length]).join("")}async function _t(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 se(n){var i,s;let e=a=>n.redact?A(a).text:a,t={platform:"web",route:e(location.pathname),title:e(document.title.slice(0,200)),locale:navigator.language,timezone:At(),viewport:{width:window.innerWidth,height:window.innerHeight,dpr:(i=window.devicePixelRatio)!=null?i:1},device:St(),sdk:{name:"js",version:I}};document.referrer&&(t.referrer=N(document.referrer)),n.app&&(t.app=n.app);let o=((s=n.anchors)!=null?s:[]).map(a=>n.redact?{...a,elementText:a.elementText===null?null:e(a.elementText),...a.page===void 0?{}:{page:e(a.page)}}:a);o[0]&&(t.anchor=o[0]),o.length>1&&(t.anchors=o),n.breadcrumbs&&n.breadcrumbs.length>0&&(t.breadcrumbs=n.breadcrumbs);let r=n.withheld;return r&&(r.blurredByReporter>0||Object.values(r.secretsMasked).some(a=>(a!=null?a:0)>0))&&(t.redaction=r),t}function St(){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 At(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return`UTC${-new Date().getTimezoneOffset()/60}`}}async function Ie(n,e=()=>()=>{},t=[]){var c;if(typeof((c=navigator.mediaDevices)==null?void 0:c.getDisplayMedia)!="function")return null;let o=Ct(n,t),r=()=>n?Pt():{boxes:[],count:0},i=r(),s=e(i.boxes),a=null;try{if(a=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),!a.getVideoTracks()[0])return null;i=r(),s(),s=e(i.boxes),await new Promise(h=>setTimeout(h,250));let d=await $t(a);return d?{...d,secretsMasked:i.count}:null}catch{return null}finally{a==null||a.getTracks().forEach(l=>l.stop()),s(),o()}}var Ce=1920,Tt=.82;async function $t(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>Ce?Ce/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 Lt(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 Lt(n){for(let e of["image/webp","image/jpeg"]){let t=await Re(n,e,Tt);if((t==null?void 0:t.type)===e)return t}return Re(n,"image/png")}function Re(n,e,t){return new Promise(o=>n.toBlob(r=>o(r),e,t))}function Ct(n,e){let t=[...n?document.querySelectorAll(`[${L}]`):[],...n?document.querySelectorAll('input[type="password"]'):[],...e.filter(r=>"style"in r)],o=t.map(r=>r.style.filter);return t.forEach(r=>{r.style.filter="blur(12px)"}),()=>{t.forEach((r,i)=>{var s;r.style.filter=(s=o[i])!=null?s:""})}}var Rt=new Set(["script","style","noscript","template"]),Mt=/^(?:text|search|url|email|tel|number|)$/,It=1,Nt=4,zt=1,Ot=2;function Pt(){let n=[],e=0,t=document.body;if(!t)return{boxes:n,count:e};let o=document.createTreeWalker(t,It|Nt,{acceptNode:s=>s.nodeType===1&&Rt.has(s.localName)?Ot:zt}),r="",i=o.nextNode();for(;i;){if(i.nodeType===3){let a=[i];for(i=o.nextNode();i&&i.nodeType===3&&i.previousSibling===a[a.length-1];)a.push(i),i=o.nextNode();let c=a.map(l=>l.data).join("");for(let l of H(c,r)){let d=Me(Bt(a,l.start,l.end));d.length!==0&&(n.push(...d),e+=1)}c.trim()&&(r=`${c.replace(/\s+/g," ").slice(-48)} `);continue}let s=i;if(s.localName==="textarea"||s.localName==="input"&&Mt.test(s.type)){let a=s,c=a.getAttribute("aria-label")||a.name||a.id||"";if(a.value&&H(a.value,`${r}${c} `).length>0){let l=Me([a.getBoundingClientRect()]);l.length>0&&(n.push(...l),e+=1)}}i=o.nextNode()}return{boxes:n,count:e}}function Bt(n,e,t){let o=document.createRange(),r=0,i=!1;for(let s of n){let a=s.data.length;if(!i&&e<r+a&&(o.setStart(s,e-r),i=!0),i&&t<=r+a){o.setEnd(s,t-r);break}r+=a}return Array.from(o.getClientRects(),s=>({left:s.left,top:s.top,width:s.width,height:s.height}))}function Me(n){return n.filter(e=>e.width>0&&e.height>0&&e.left<window.innerWidth&&e.left+e.width>0&&e.top<window.innerHeight&&e.top+e.height>0)}var Ne="data-daybook-blurred";function P(n,e){return n.left<e.left+e.width&&e.left<n.left+n.width&&n.top<e.top+e.height&&e.top<n.top+n.height}function ze(n,e){return n.left>=e.left-1&&n.top>=e.top-1&&n.left+n.width<=e.left+e.width+1&&n.top+n.height<=e.top+e.height+1}var Y=4e5,q=300,B=600,K=8e3,W=400,Ft=48,Ut=new Set(["SCRIPT","NOSCRIPT","TEMPLATE"]),Ht=["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"],Dt="The page at the moment this was reported. Field values are described rather than reproduced when redacted is true, data-daybook-private subtrees are withheld, and credentials found on the page read [masked: kind]. data-daybook-blurred marks what the reporter chose to blur. 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 ce(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(" > ")}function Xt(n,e,t,o){var i;let r=o;if(n.redacted){let s=(i=[e.getAttribute("name"),e.getAttribute("id")].find(c=>c&&ke.test(c)))!=null?i:t,a=A(o.slice(0,q+W),`${s}=`);n.secrets+=a.count,r=a.text}return o.length>q||r.length>q?`${r.slice(0,q)}\u2026[${o.length}]`:r}var ae=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function jt(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?Ee(o,t.name||t.id||t.type):o}function Oe(n,e){let t=n.map(i=>{var s;return(s=i.textContent)!=null?s:""}).join("").replace(/\s+/g," ");if(!t.trim())return;if(e.regions.length>0&&n.some(i=>qt(i,e.regions))){e.out.push("[withheld]"),e.used+=10,e.before="";return}let o=t.length>B+W?t.slice(0,B+W):t;if(e.redacted){let i=A(o,e.before);e.secrets+=i.count,o=i.text}e.before=`${t.slice(-Ft)} `;let r=t.length>B||o.length>B?`${o.slice(0,B)}\u2026`:o;e.out.push(ae(r)),e.used+=r.length}function qt(n,e){let t=document.createRange();return t.selectNodeContents(n),Array.from(t.getClientRects()).some(o=>e.some(r=>P(o,r)))}function Kt(n,e){let t=n.getBoundingClientRect();if(t.width===0&&t.height===0)return!1;let o=n.childNodes.length===0||Yt.has(n.localName);return e.some(r=>ze(t,r)||o&&P(t,r))}var Yt=new Set(["input","textarea","select"]);function Be(n,e){var c,l;if(e.used>Y)return!1;if(n.nodeType===3)return Oe([n],e),!0;if(n.nodeType!==1)return!0;let t=n,o=t.tagName;if(t.hasAttribute("data-daybook-feedback")||Ut.has(o))return!0;let r=t.localName;if(e.redacted&&t.hasAttribute(L))return e.out.push(`<${r} ${L}>[withheld]</${r}>`),e.used+=32,e.before="",!0;if(e.blurred.has(t)||e.regions.length>0&&Kt(t,e.regions))return e.out.push(`<${r} ${Ne}>[withheld]</${r}>`),e.used+=32,e.before="",!0;let i=[];for(let d of Array.from(t.attributes)){if(d.name==="value")continue;let h=Xt(e,t,d.name,d.value);i.push(`${d.name}="${ae(h)}"`)}let s=jt(t,e.redacted);s!==null&&i.push(`value="${ae(s)}"`);let a=i.length>0?`<${r} ${i.join(" ")}>`:`<${r}>`;if(e.out.push(a),e.used+=a.length,r==="style"){let d=(c=t.textContent)!=null?c:"",h=d.slice(0,K+W);if(e.redacted){let p=A(h);e.secrets+=p.count,h=p.text}let f=d.length>K||h.length>K?`${h.slice(0,K)}
|
|
2
|
+
/* \u2026${d.length} chars */`:h;e.out.push(f),e.used+=f.length}else{let d=Array.from(t.childNodes);for(let h=0;h<d.length;h+=1){let f=d[h];if(f.nodeType===3){let p=[f];for(;((l=d[h+1])==null?void 0:l.nodeType)===3;)p.push(d[++h]);if(Oe(p,e),e.used>Y)break;continue}if(!Be(f,e))break}}return e.out.push(`</${r}>`),e.used+=r.length+3,e.used<=Y}function Wt(){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:ce(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 Pe(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 Ht){let a=r.getPropertyValue(s);a&&(i[s]=a)}t.push({selector:ce(o),computed:i})}return{selector:n.selector,path:t}}function Vt(){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 Fe(n,e,t={elements:[],regions:[]}){var r;let o=n==null?[]:Array.isArray(n)?n:[n];try{let i={out:[],used:0,redacted:e,blurred:new Set(t.elements),regions:t.regions,before:"",secrets:0};Be(document.documentElement,i);let s=d=>{if(!e)return d;let h=A(d);return i.secrets+=h.count,h.text},a=s(location.href),c=s(document.title),l=Vt().map(d=>d.href?{...d,href:s(d.href)}:d);return{note:Dt,capturedAtUtc:new Date().toISOString(),url:a,title:c,redacted:e,blurredByReporter:t.elements.length+t.regions.length,secretsMasked:i.secrets,truncated:i.used>Y,scroll:{x:Math.round(window.scrollX),y:Math.round(window.scrollY)},focus:document.activeElement&&document.activeElement!==document.body?ce(document.activeElement):null,anchor:Pe((r=o[0])!=null?r:null),anchors:o.length>1?o.map(d=>Pe(d)).filter(d=>!!d):void 0,layers:Wt(),stylesheets:l,html:i.out.join("")}}catch{return null}}function Z(n,e){let t=document.elementFromPoint(n,e);if(!(t instanceof HTMLElement))return{selector:null,offsetX:V(n/window.innerWidth),offsetY:V(e/window.innerHeight),elementText:null,page:Ue()};let o=t.getBoundingClientRect();return{selector:Zt(t),offsetX:o.width>0?V((n-o.left)/o.width):0,offsetY:o.height>0?V((e-o.top)/o.height):0,elementText:Qt(t),page:Ue()}}function He(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 Zt(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}="${F(i)}"]`;if(C(s))return s}}if(n.id&&!le(n.id)){let r=`#${F(n.id)}`;if(C(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=>!le(c)).slice(0,2);i.length>0&&(r+=i.map(c=>`.${F(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(C(a))return a;t=s}let o=e.length>0?`body > ${e.join(" > ")}`:null;return o&&C(o)?o:Gt(n)}function Gt(n){let e=[],t=n;for(;t&&t!==document.body&&t!==document.documentElement;){let r=Jt(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&&C(o)?o:null}function Jt(n){for(let e of["data-testid","data-test","data-daybook-id","data-cy"]){let t=n.getAttribute(e);if(t){let o=`[${e}="${F(t)}"]`;if(C(o))return o}}if(n.id&&!le(n.id)){let e=`#${F(n.id)}`;if(C(e))return e}return null}function C(n){try{return document.querySelectorAll(n).length===1}catch{return!1}}function le(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 Qt(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 Ue(){return location.pathname+location.search}function V(n){return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0}function F(n){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/([^\w-])/g,"\\$1")}var en=/^(image\/(png|jpeg|gif|webp)|video\/(mp4|quicktime|webm))$/;function De(n,e){let t=[];for(let o of n){if(e+t.length>=5)break;let r=en.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}.${tn(o.type)}`,contentType:o.type,preview:r?null:URL.createObjectURL(o),error:r})}return t}function Xe(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 G(n){for(let e of n)e.preview&&URL.revokeObjectURL(e.preview)}function tn(n){var e,t;return(t=(e=n.split("/")[1])==null?void 0:e.replace("quicktime","mov"))!=null?t:"bin"}function je(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 nn(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 on(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 rn(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)||!on(l,e,t))continue;let d=l.getBoundingClientRect();o.set(l,{top:d.top,bottom:d.bottom,left:d.left,right:d.right})}}return[...o.values()]}function qe(n,e){let t={width:window.innerWidth,height:window.innerHeight};return nn(n,rn(n,e,t),t)}var Q=class{constructor(e,t){this.options=e,this.onSubmit=t,this.mode="idle",this.pins=[],this.blurs=[],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=cn(),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>${at}</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=tt(e),this.buttonStyle=nt(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=y+this.clearance;e.textContent=`:host {
|
|
3
|
+
--pm-${r}: ${y}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-
|
|
5
|
+
}`}homeSlot(){let e=this.placement,t=220,o=48,r=e.endsWith("right")?window.innerWidth-y:y+t,i=e.startsWith("bottom")?window.innerHeight-y:y+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=qe(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 Ke)window.addEventListener(o,e,!0);this.detach.push(()=>{for(let o of Ke)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.blurs=[],this.dragged=null,this.render());return}r.metaKey||r.ctrlKey||r.altKey||je(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(e=[]){let t=this.root.getElementById("layer"),o=t.style.visibility;t.style.visibility="hidden";let r=this.origin(),i=[...this.veilBlurs(this.root),...e.map(s=>this.root.appendChild(Ve(s,r,null,!0))),...this.ringPins()];return()=>{t.style.visibility=o,i.forEach(s=>s.remove())}}blurred(){let e=[],t=[];for(let o of this.blurs){let r=this.pinRect(o);if(!r)continue;let i=this.elementOf(o);i?e.push(i):t.push(r)}return{elements:e,regions:t}}elementOf(e){var t,o;if(((t=e.anchor.page)!=null?t:U())!==U())return null;if((o=e.element)!=null&&o.isConnected)return e.element;if(!e.anchor.selector||e.anchor.selector==="body")return null;try{return document.querySelector(e.anchor.selector)}catch{return null}}veilBlurs(e){let t=this.origin(),o=this.blurs.length>1;return this.blurs.flatMap((r,i)=>{let s=this.pinRect(r);if(!s)return[];let a=o?`Blurred ${i+1}`:"Blurred";return[e.appendChild(Ve(s,t,a,!1))]})}sendable(e){if(!e.anchor.elementText)return e.anchor;let t=this.elementOf(e),o=this.pinRect(e),r=this.blurs.some(a=>{let c=this.elementOf(a);if(c&&t)return c.contains(t)||t.contains(c);let l=this.pinRect(a);return!!l&&!!o&&P(l,o)}),i=`[${L}]`;return r||this.options.redact!==!1&&!!t&&(!!t.closest(i)||!!t.querySelector(i))?{...e.anchor,elementText:null}:e.anchor}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-$}px`,s.style.top=`${r.top-i.top-$}px`,s.style.width=`${r.width+$*2}px`,s.style.height=`${r.height+$*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:U())!==U())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.veilBlurs(t),this.pins.length<1)return;let a=this.origin();this.pins.forEach((c,l)=>{let d=this.pinRect(c);if(!d)return;let h=document.createElement("div");h.className="marker",h.style.left=`${d.left-a.left-$}px`,h.style.top=`${d.top-a.top-$}px`,h.style.width=`${d.width+$*2}px`,h.style.height=`${d.height+$*2}px`;let f=document.createElement("span");f.className="marker__n",f.textContent=String(l+1),h.appendChild(f),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,o=!1){let r=this.root.getElementById("layer"),i=()=>{var a;s.remove(),e.style.visibility="",this.cancelAdding=null,(a=this.redrawMarks)==null||a.call(this)},s=o?this.picker(a=>{this.blurs.push(a),i(),t()},"Click what to blur, or drag across an area",!0):this.picker(a=>{this.pins.push(a),i(),t()},`Click what else is involved (pin ${this.pins.length+1})`);e.style.visibility="hidden",this.cancelAdding=i,r.appendChild(s)}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 d=z(l.clientX-i,y-r.width+de,window.innerWidth-de),h=z(l.clientY-s,0,window.innerHeight-de);e.style.left=`${d}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=Ge(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}We(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}We(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)<Ye)return;s=!0,e.classList.add("launcher--dragging")}e.style.left=`${z(l.clientX-r,0,window.innerWidth-o.width)}px`,e.style.top=`${z(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=Ge(e.getBoundingClientRect()),ln(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">${J(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 an(t);a.textContent=l?"Copied":"Copy failed",a.classList.toggle("sent__copy--done",l)}),e}launcher(){var t,o;let e=ot(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",o=!1){let r=document.createElement("div");r.className=o?"mask mask--blur":"mask",r.innerHTML=`<div class="${o?"hover hover--blur":"hover"}" hidden></div><div class="hint">${J(t)} \xB7 <kbd>Esc</kbd> to cancel</div>`;let i=r.querySelector(".hover"),s=null,a=null,c=!1,l=f=>{let p=this.origin();i.hidden=!1,i.style.left=`${f.left-p.left}px`,i.style.top=`${f.top-p.top}px`,i.style.width=`${f.width}px`,i.style.height=`${f.height}px`};if(o){let f=m=>({left:Math.min(a.x,m.clientX),top:Math.min(a.y,m.clientY),width:Math.abs(m.clientX-a.x),height:Math.abs(m.clientY-a.y)});r.addEventListener("pointerdown",m=>{m.button===0&&(a={x:m.clientX,y:m.clientY},r.setPointerCapture(m.pointerId))}),r.addEventListener("pointermove",m=>{a&&(!s&&Math.hypot(m.clientX-a.x,m.clientY-a.y)<Ye||(s=f(m),l(s)))});let p=m=>{r.hasPointerCapture(m.pointerId)&&r.releasePointerCapture(m.pointerId);let g=s;a=null,s=null,!(!g||m.type==="pointercancel")&&(c=!0,e==null||e(un(g)))};r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}let d=(f,p)=>{r.style.pointerEvents="none";let m=document.elementFromPoint(f,p);return r.style.pointerEvents="",m},h=0;return r.onmousemove=f=>{if(h||s)return;let{clientX:p,clientY:m}=f;h=requestAnimationFrame(()=>{if(h=0,s)return;let g=d(p,m);if(!g||g===document.body||g===document.documentElement){i.hidden=!0;return}let v=g.getBoundingClientRect();l({left:v.left,top:v.top,width:v.width,height:v.height})})},r.onclick=f=>{if(c){c=!1;return}r.style.pointerEvents="none";let p=pn(f.clientX,f.clientY);if(r.style.pointerEvents="",o){if(!p.element)return;e==null||e({...p,anchor:{...p.anchor,elementText:null}});return}if(e){e(p);return}this.pins=[p],this.blurs=[],this.mode="composing",this.render()},r}composer(){var me,ge,be;let e=document.createElement("div");e.className="panel";let t=Ze(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">${J(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>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
what somebody came here to do is type.
|
|
35
35
|
-->
|
|
36
36
|
<div class="panel__kinds">
|
|
37
|
-
${["bug","idea","praise","question"].map((u,
|
|
37
|
+
${["bug","idea","praise","question"].map((u,w)=>`<button class="kind${w===0?" kind--on":""}" data-kind="${u}">${u}</button>`).join("")}
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
40
|
<input id="email" type="email" placeholder="Email (optional, so we can reply)" autocomplete="email" />
|
|
@@ -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,
|
|
63
|
+
</div>`;let r=[],i=e.querySelector("#files"),s=e.querySelector("#drop"),a=e.querySelector("#file"),c=()=>{i.innerHTML="",r.forEach((u,w)=>{var S;let b=document.createElement("div");b.className=u.error?"file file--bad":"file",b.innerHTML=u.preview?`<img src="${u.preview}" alt="" />`:'<span class="file__icon">\u25A6</span>';let k=document.createElement("span");k.className="file__name",k.textContent=(S=u.error)!=null?S:u.filename,b.appendChild(k);let x=document.createElement("button");x.className="link",x.textContent="\xD7",x.onclick=()=>{G([u]),r.splice(w,1),c()},b.appendChild(x),i.appendChild(b)}),s.style.display=r.length>=5?"none":""},l=u=>{r.push(...De(u,r.length)),c()};a.onchange=()=>{a.files&&l(a.files)},e.querySelector("#browse").onclick=()=>a.click(),e.addEventListener("paste",u=>{let w=Xe(u);w.length>0&&(u.preventDefault(),l(w))}),s.addEventListener("dragover",u=>{u.preventDefault(),s.classList.add("drop--over")}),s.addEventListener("dragleave",()=>s.classList.remove("drop--over")),s.addEventListener("drop",u=>{var w,b;u.preventDefault(),s.classList.remove("drop--over"),l(Array.from((b=(w=u.dataTransfer)==null?void 0:w.files)!=null?b:[]))});let d="bug";e.querySelectorAll(".kind").forEach(u=>{u.onclick=()=>{var w;d=(w=u.dataset.kind)!=null?w:"bug",e.querySelectorAll(".kind").forEach(b=>b.classList.remove("kind--on")),u.classList.add("kind--on")}});let h=e.querySelector("#pins"),f=e.querySelector(".panel__anchor"),p=()=>{var w;f.textContent=Ze(this.pins),h.innerHTML="",this.pins.length>1&&this.pins.forEach((b,k)=>{var we;let x=document.createElement("div");x.className="pin";let S=document.createElement("span");S.className="pin__n",S.textContent=String(k+1),x.appendChild(S);let T=document.createElement("span");T.className="pin__label",T.textContent=et(b.anchor),T.title=(we=b.anchor.page)!=null?we:"",x.appendChild(T);let E=document.createElement("button");E.className="link",E.textContent="\xD7",E.setAttribute("aria-label",`Remove pin ${k+1}`),E.onclick=()=>{this.pins.splice(k,1),p()},x.appendChild(E),h.appendChild(x)}),this.blurs.forEach((b,k)=>{let x=document.createElement("div");x.className="pin";let S=document.createElement("span");S.className="pin__n pin__n--blur",S.textContent=String(k+1),x.appendChild(S);let T=document.createElement("span");T.className="pin__label",T.textContent=fn(b),x.appendChild(T);let E=document.createElement("button");E.className="link",E.textContent="\xD7",E.setAttribute("aria-label",`Remove blur ${k+1}`),E.onclick=()=>{this.blurs.splice(k,1),p()},x.appendChild(E),h.appendChild(x)});let u=document.createElement("div");if(u.className="pins__actions",this.pins.length<dn){let b=document.createElement("button");b.className="link pins__add",b.id="add-pin",b.textContent=this.pins.length>0?"+ Add another pin":"+ Pin something on the page",b.onclick=()=>this.pickAnother(e,p),u.appendChild(b)}if(this.blurs.length<hn){let b=document.createElement("button");b.className="link pins__add",b.id="add-blur",b.textContent=this.blurs.length>0?"Blur something else":"Blur something",b.title="Hide part of the page from the screenshot and the page snapshot",b.onclick=()=>this.pickAnother(e,p,!0),u.appendChild(b)}u.childElementCount>0&&h.appendChild(u),(w=this.redrawMarks)==null||w.call(this)};p();let m=e.querySelector("#message"),g=e.querySelector("#email"),v=(be=(me=this.reporter)==null?void 0:me.email)!=null?be:(ge=this.options.reporter)==null?void 0:ge.email;v&&!g.value&&(g.value=v);let _=e.querySelector("#shot"),R=e.querySelector("#status"),M=e.querySelector("#send"),ue=()=>{G(r),this.mode="idle",this.pins=[],this.blurs=[],this.dragged=null,this.render()};e.querySelector("#cancel").onclick=ue,e.querySelector("#close").onclick=ue;let fe=async()=>{var u;if(!m.value.trim()){R.textContent="Say what happened first.";return}M.disabled=!0,R.textContent="Sending\u2026";try{let w=await this.onSubmit({message:m.value.trim(),kind:d,email:g.value.trim()||void 0,anchors:this.pins.map(b=>this.sendable(b)),withScreenshot:(u=_==null?void 0:_.checked)!=null?u:!1,files:r.filter(b=>!b.error)});this.reference=w.reference,this.uploadsFailed=w.uploadsFailed,G(r),this.mode="sent",this.pins=[],this.blurs=[],this.render()}catch(w){M.disabled=!1,R.textContent=w instanceof Error?`${w.message} \u2014 saved, will retry.`:"Failed, saved and will retry."}};return M.onclick=fe,m.onkeydown=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&fe()},setTimeout(()=>m.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 an(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 y=16,$=3,Ke=["focus","focusin","mousedown","touchstart","click"],Ye=5,Qe="daybook-feedback:launcher";function cn(){var n;try{let e=JSON.parse((n=localStorage.getItem(Qe))!=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 ln(n){try{localStorage.setItem(Qe,JSON.stringify(n))}catch{}}function We(n,e,t,o){let r=z(e.dx,y,Math.max(y,window.innerWidth-t-y)),i=z(e.dy,y,Math.max(y,window.innerHeight-o-y));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 dn=10,hn=10;function U(){return location.pathname+location.search}function pn(n,e){let t=Z(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 un(n){return{anchor:{selector:null,offsetX:0,offsetY:0,elementText:null,page:U()},element:null,box:{left:n.left+window.scrollX,top:n.top+window.scrollY,width:n.width,height:n.height}}}function fn(n){let e=`${Math.round(n.box.width)} \xD7 ${Math.round(n.box.height)}`;return`${n.element?"Blurred element":"Blurred area"} \xB7 ${e}`}function Ve(n,e,t,o){let r=o?2:0,i=document.createElement("div");if(i.className=o?"veil veil--secret":"veil",i.style.left=`${n.left-e.left-r}px`,i.style.top=`${n.top-e.top-r}px`,i.style.width=`${n.width+r*2}px`,i.style.height=`${n.height+r*2}px`,t&&n.width>=72&&n.height>=22){let s=document.createElement("span");s.className="veil__tag",s.textContent=t,i.appendChild(s)}return i}function et(n){return n.elementText?`\u201C${n.elementText}\u201D`:n.selector&&n.selector!=="body"?n.selector:"a spot on the page"}function Ze(n){if(n.length===0)return"on this page";let[e]=n;if(!e)return"on this page";let t=`on ${et(e.anchor)}`;return n.length===1?t:`${t} and ${n.length-1} more`}var de=56;function Ge(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?y:Math.max(y,Math.round(e[o])),dy:t===r?y:Math.max(y,Math.round(e[r]))}}function z(n,e,t){return Math.min(Math.max(n,e),t)}function J(n){return n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function mn(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 Je='<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 tt(n){var o;let e=[];mn(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(st):n.colorScheme==="light"&&e.push(it),e.length>0?`:host { ${e.join("; ")} }`:""}var nt=n=>gn.includes(n.buttonStyle)?n.buttonStyle:"pill";function ot(n,e){let t=document.createElement("button");return t.className=`launcher launcher--${n}`,n==="icon"?(t.innerHTML=Je,t.setAttribute("aria-label",e)):n==="pill-icon"?t.innerHTML=`${Je}<span>${J(e)}</span>`:t.textContent=e,t}function rt(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>${at}</style><style>${tt(e)}</style>`;let r=ot(nt(e),o);r.classList.add("launcher--preview"),r.disabled=!0,t.appendChild(r)}var gn=["pill","pill-icon","icon","text","outline"],it="--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;",st="--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;",at=`
|
|
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
|
+
${it}
|
|
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 { ${st} }
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
* { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
|
|
@@ -189,6 +189,47 @@
|
|
|
189
189
|
position: fixed; pointer-events: none; border-radius: 3px;
|
|
190
190
|
border: 2px solid #ef4444; box-shadow: 0 0 0 2px rgba(255,255,255,.85);
|
|
191
191
|
}
|
|
192
|
+
/*
|
|
193
|
+
A blur (PM-T-0682): the reporter's, on the page while they write and in the picture after.
|
|
194
|
+
|
|
195
|
+
A backdrop filter, so it blurs what is painted under it and touches nothing of the host's. The grey
|
|
196
|
+
tint and the hairline make it read as a cover rather than as a page that failed to render. Neutral,
|
|
197
|
+
not red: red on this layer means "this is what the report is about", and a blur means the opposite.
|
|
198
|
+
*/
|
|
199
|
+
.veil {
|
|
200
|
+
position: fixed; pointer-events: none; border-radius: 3px;
|
|
201
|
+
-webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
|
|
202
|
+
background: rgba(115,115,115,.35);
|
|
203
|
+
box-shadow: inset 0 0 0 1px rgba(255,255,255,.55), 0 0 0 1px rgba(23,23,23,.3);
|
|
204
|
+
}
|
|
205
|
+
/*
|
|
206
|
+
Solid where nothing can be blurred behind an element: a cover that shows what it covers is worse
|
|
207
|
+
than a grey box. That is Firefox before 103 and Chrome before 76, which say so.
|
|
208
|
+
|
|
209
|
+
One engine has been seen to claim it and not draw it \u2014 WebKit's Windows port, which no shipping
|
|
210
|
+
browser uses \u2014 and the preview there is a tint over legible text. It has no getDisplayMedia, so it
|
|
211
|
+
never takes a picture; the snapshot does not depend on any of this; and an element blur is also
|
|
212
|
+
blurred on the element itself for the frame (screenshot.ts). Checked drawing in Chromium.
|
|
213
|
+
*/
|
|
214
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
215
|
+
.veil { background: #8a8a8a }
|
|
216
|
+
}
|
|
217
|
+
/* Over a credential the capture found: solid, because a blurred key of a known shape can sometimes be
|
|
218
|
+
read back, and nobody needs its shape to understand the report. */
|
|
219
|
+
.veil--secret { background: #737373; box-shadow: none; border-radius: 2px }
|
|
220
|
+
.veil__tag {
|
|
221
|
+
position: absolute; right: 3px; bottom: 3px; padding: 0 5px; border-radius: 4px;
|
|
222
|
+
background: rgba(23,23,23,.72); color: #fff; font: 600 10px/16px system-ui, sans-serif;
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
}
|
|
225
|
+
/* What a click would blur, blurred already: the reporter sees the result before committing to it. */
|
|
226
|
+
.hover--blur {
|
|
227
|
+
outline-color: #525252;
|
|
228
|
+
-webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
|
|
229
|
+
background: rgba(115,115,115,.25);
|
|
230
|
+
}
|
|
231
|
+
/* A touch drag draws the area rather than scrolling the page underneath it. */
|
|
232
|
+
.mask--blur { touch-action: none }
|
|
192
233
|
/*
|
|
193
234
|
Bottom, not top.
|
|
194
235
|
|
|
@@ -242,6 +283,8 @@ kbd {
|
|
|
242
283
|
font: 600 11px/18px system-ui, sans-serif; text-align: center;
|
|
243
284
|
}
|
|
244
285
|
.pin__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
286
|
+
.pin__n--blur { background: #737373 }
|
|
287
|
+
.pins__actions { display: flex; flex-wrap: wrap; gap: 4px 14px }
|
|
245
288
|
.pins__add { align-self: flex-start; font-size: 12px; }
|
|
246
289
|
.panel__anchor {
|
|
247
290
|
color: var(--pm-muted); font-size: 11px;
|
|
@@ -340,4 +383,4 @@ textarea:focus, input:focus { outline: 2px solid var(--pm-ink); outline-offset:
|
|
|
340
383
|
.file__icon { width: 28px; text-align: center }
|
|
341
384
|
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
|
|
342
385
|
.link { border: 0; background: transparent; color: var(--pm-muted); cursor: pointer; font-size: 11px; text-decoration: underline }
|
|
343
|
-
`;var
|
|
386
|
+
`;var ct=Symbol.for("daybook.modules");function bn(){var e;let n=globalThis;return(e=n[ct])!=null?e:n[ct]=new Map}function he(n,e){let t=bn();t.has(n)||t.set(n,e)}var pe=class{constructor(){this.name="feedback",this.widget=null,this.userId=null}start(e){var i,s,a,c;if(e.key==="")throw new Error("there is no key to file reports with");let{autoStart:t,...o}=(i=e.options.feedback)!=null?i:{},r=new O({...o,ingestKey:e.key,apiUrl:(s=o.apiUrl)!=null?s:e.serverUrl,reporter:e.user?{...o.reporter,...lt(e.user)}:o.reporter});return this.widget=r,this.userId=(c=(a=e.user)==null?void 0:a.id)!=null?c:null,e.browser&&t!==!1&&r.start(),r}identify(e){var t,o;this.userId!==null&&this.userId!==e.id&&((t=this.widget)==null||t.identify(null)),this.userId=e.id,(o=this.widget)==null||o.identify(lt(e))}reset(){var e;this.userId=null,(e=this.widget)==null||e.identify(null)}};function lt(n){let e={externalId:n.id};return n.email&&(e.email=n.email),n.name&&(e.name=n.name),e}he("feedback",()=>new pe);var dt="https://api.daybook.team",O=class{constructor(e){var t;if(this.options=e,this.widget=null,this.started=!1,this.inFlight=null,this.epoch=0,this.ready=null,this.stopped=!1,!e.ingestKey)throw new Error("ingestKey is required");this.client=new j((t=e.apiUrl)!=null?t:dt,e.ingestKey),this.trail=e.breadcrumbs===!1?null:new D(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 Q(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:I}});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(xn(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:{...se({breadcrumbs:(o=this.trail)==null?void 0:o.list(),app:this.options.app,redact:this.options.redact!==!1}),...(r=t.context)!=null?r:{}},reporter:(i=t.reporter)!=null?i:this.options.reporter})}async submit(e){var d,h,f,p,m;let t=this.options.redact!==!1,o=()=>{var g,v;return(v=(g=this.widget)==null?void 0:g.blurred())!=null?v:{elements:[],regions:[]}},r=o(),i=e.withScreenshot?await Ie(t,g=>{var v,_;return(_=(v=this.widget)==null?void 0:v.conceal(g))!=null?_:(()=>{})},r.elements):null,s=this.options.dom===!1?null:Fe(e.anchors,t,o()),a=[...e.files,...i?[i]:[],...s?[wn(s)]:[]],c={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:se({anchors:e.anchors,breadcrumbs:(d=this.trail)==null?void 0:d.list(),app:this.options.app,redact:t,withheld:{blurredByReporter:r.elements.length+r.regions.length,secretsMasked:{...i?{screenshot:i.secretsMasked}:{},...s?{snapshot:s.secretsMasked}:{}}}})},l=[];try{let g=await this.client.send(c,a,(v,_)=>{var R,M;l.push(_),console.warn(`[feedback] "${v.filename}" did not upload`,_),(M=(R=this.options).onError)==null||M.call(R,_)});return g.uploadsFailed=l.length,(f=(h=this.options).onSent)==null||f.call(h,g),{reference:g.reference,uploadsFailed:l.length}}catch(g){throw this.client.queue(c),(m=(p=this.options).onError)==null||m.call(p,g),g}}};function wn(n){let e=JSON.stringify(n);return{blob:new Blob([e],{type:"application/json"}),filename:"page-snapshot.json",contentType:"application/json"}}function yn(n){return new O(n).start()}function xn(n){if(!n)return null;try{let e=JSON.parse(n);return e&&typeof e=="object"?e:null}catch{return null}}return gt(vn);})();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IngestRequest, IngestResponse, FeedbackOptions } from './types.js';
|
|
2
|
+
import './module.js';
|
|
3
|
+
export type { FeedbackModuleOptions } from './module.js';
|
|
2
4
|
export type { Anchor, Breadcrumb, FeedbackKind, FeedbackTheme, HandshakeRequest, HandshakeResponse, IngestRequest, IngestResponse, FeedbackOptions, ReporterStatus, } from './types.js';
|
|
3
5
|
/**
|
|
4
6
|
* Where reports go unless the host says otherwise.
|
|
@@ -19,6 +21,16 @@ export { previewLauncher, type ButtonStyle } from './widget.js';
|
|
|
19
21
|
/**
|
|
20
22
|
* In-app feedback for the web.
|
|
21
23
|
*
|
|
24
|
+
* Started with Daybook's core and the site's one key, it is `daybook.feedback`:
|
|
25
|
+
*
|
|
26
|
+
* import { Daybook } from '@daybook/core'
|
|
27
|
+
* import '@daybook/feedback'
|
|
28
|
+
*
|
|
29
|
+
* const daybook = await Daybook.initialize('dbk_…', { feedback: { app: { version: '1.4.0' } } })
|
|
30
|
+
* daybook.feedback.open()
|
|
31
|
+
*
|
|
32
|
+
* Or by itself, the way before the core, kept for sites that use it:
|
|
33
|
+
*
|
|
22
34
|
* import { init } from '@daybook/feedback'
|
|
23
35
|
*
|
|
24
36
|
* init({
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { captureContext } from './context.js';
|
|
|
5
5
|
import { captureScreenshot } from './screenshot.js';
|
|
6
6
|
import { captureSnapshot } from './snapshot.js';
|
|
7
7
|
import { FeedbackWidget } from './widget.js';
|
|
8
|
+
import './module.js';
|
|
8
9
|
/**
|
|
9
10
|
* Where reports go unless the host says otherwise.
|
|
10
11
|
*
|
|
@@ -24,6 +25,16 @@ export { previewLauncher } from './widget.js';
|
|
|
24
25
|
/**
|
|
25
26
|
* In-app feedback for the web.
|
|
26
27
|
*
|
|
28
|
+
* Started with Daybook's core and the site's one key, it is `daybook.feedback`:
|
|
29
|
+
*
|
|
30
|
+
* import { Daybook } from '@daybook/core'
|
|
31
|
+
* import '@daybook/feedback'
|
|
32
|
+
*
|
|
33
|
+
* const daybook = await Daybook.initialize('dbk_…', { feedback: { app: { version: '1.4.0' } } })
|
|
34
|
+
* daybook.feedback.open()
|
|
35
|
+
*
|
|
36
|
+
* Or by itself, the way before the core, kept for sites that use it:
|
|
37
|
+
*
|
|
27
38
|
* import { init } from '@daybook/feedback'
|
|
28
39
|
*
|
|
29
40
|
* init({
|
|
@@ -248,19 +259,29 @@ export class DaybookFeedback {
|
|
|
248
259
|
surface: this.options.surface,
|
|
249
260
|
...extra,
|
|
250
261
|
context: {
|
|
251
|
-
...captureContext({
|
|
262
|
+
...captureContext({
|
|
263
|
+
breadcrumbs: this.trail?.list(),
|
|
264
|
+
app: this.options.app,
|
|
265
|
+
redact: this.options.redact !== false,
|
|
266
|
+
}),
|
|
252
267
|
...(extra.context ?? {}),
|
|
253
268
|
},
|
|
254
269
|
reporter: extra.reporter ?? this.options.reporter,
|
|
255
270
|
});
|
|
256
271
|
}
|
|
257
272
|
async submit(input) {
|
|
273
|
+
const redact = this.options.redact !== false;
|
|
274
|
+
// What the reporter blurred (PM-T-0682). Applied to both captures whatever `redact` says — it is
|
|
275
|
+
// their decision, made while looking at the page — and asked for again before each, because the
|
|
276
|
+
// screen share's prompt can be up for a while and an element's box with it.
|
|
277
|
+
const blurred = () => this.widget?.blurred() ?? { elements: [], regions: [] };
|
|
278
|
+
const blurs = blurred();
|
|
258
279
|
// The reporter's tick is the answer. It used to be second-guessed here against
|
|
259
280
|
// options.screenshots, so a host that set `screenshots: false` still rendered the checkbox and
|
|
260
281
|
// then quietly ignored it — the widget now simply does not offer the control in that case, and
|
|
261
282
|
// what arrives here is a decision somebody actually made.
|
|
262
283
|
const screenshot = input.withScreenshot
|
|
263
|
-
? await captureScreenshot(
|
|
284
|
+
? await captureScreenshot(redact, cover => this.widget?.conceal(cover) ?? (() => { }), blurs.elements)
|
|
264
285
|
: null;
|
|
265
286
|
/*
|
|
266
287
|
* The page itself, as markup rather than as a picture.
|
|
@@ -276,7 +297,7 @@ export class DaybookFeedback {
|
|
|
276
297
|
*/
|
|
277
298
|
const snapshot = this.options.dom === false
|
|
278
299
|
? null
|
|
279
|
-
: captureSnapshot(input.anchors,
|
|
300
|
+
: captureSnapshot(input.anchors, redact, blurred());
|
|
280
301
|
/*
|
|
281
302
|
* Order matters, because the server takes the first five and drops the rest without saying so.
|
|
282
303
|
*
|
|
@@ -302,6 +323,14 @@ export class DaybookFeedback {
|
|
|
302
323
|
anchors: input.anchors,
|
|
303
324
|
breadcrumbs: this.trail?.list(),
|
|
304
325
|
app: this.options.app,
|
|
326
|
+
redact,
|
|
327
|
+
withheld: {
|
|
328
|
+
blurredByReporter: blurs.elements.length + blurs.regions.length,
|
|
329
|
+
secretsMasked: {
|
|
330
|
+
...(screenshot ? { screenshot: screenshot.secretsMasked } : {}),
|
|
331
|
+
...(snapshot ? { snapshot: snapshot.secretsMasked } : {}),
|
|
332
|
+
},
|
|
333
|
+
},
|
|
305
334
|
}),
|
|
306
335
|
};
|
|
307
336
|
const failures = [];
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DaybookFeedback } from './index.js';
|
|
2
|
+
import type { FeedbackOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* What `Daybook.initialize` takes under `feedback`: every option of the widget but the ones the core
|
|
5
|
+
* holds. The key and the address are the core's, and who is reporting is `daybook.identify`.
|
|
6
|
+
*/
|
|
7
|
+
export type FeedbackModuleOptions = Omit<FeedbackOptions, 'ingestKey'> & {
|
|
8
|
+
/**
|
|
9
|
+
* `false` keeps the widget off the page until `daybook.feedback.start()`, for a site that shows it
|
|
10
|
+
* only to some people. It starts by itself otherwise.
|
|
11
|
+
*/
|
|
12
|
+
autoStart?: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare module '@daybook/core' {
|
|
15
|
+
interface Daybook {
|
|
16
|
+
/** Feedback's door: the widget, `open()`, `report()`. From `@daybook/feedback`. */
|
|
17
|
+
readonly feedback: DaybookFeedback;
|
|
18
|
+
}
|
|
19
|
+
interface DaybookOptions {
|
|
20
|
+
/** What only feedback needs: the app's version, screenshots, redaction, `autoStart`. */
|
|
21
|
+
feedback?: FeedbackModuleOptions;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { registerModule } from '@daybook/core';
|
|
2
|
+
import { DaybookFeedback } from './index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The widget as a module of Daybook's core (PM-R-0110, PM-T-0971): importing `@daybook/feedback`
|
|
5
|
+
* registers it, `Daybook.initialize` starts it with the site's one key, and `daybook.feedback` is the
|
|
6
|
+
* same object `init({ ingestKey })` used to answer.
|
|
7
|
+
*/
|
|
8
|
+
class FeedbackModule {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.name = 'feedback';
|
|
11
|
+
this.widget = null;
|
|
12
|
+
this.userId = null;
|
|
13
|
+
}
|
|
14
|
+
start(context) {
|
|
15
|
+
if (context.key === '')
|
|
16
|
+
throw new Error('there is no key to file reports with');
|
|
17
|
+
const { autoStart, ...options } = (context.options.feedback ?? {});
|
|
18
|
+
const widget = new DaybookFeedback({
|
|
19
|
+
...options,
|
|
20
|
+
ingestKey: context.key,
|
|
21
|
+
apiUrl: options.apiUrl ?? context.serverUrl,
|
|
22
|
+
reporter: context.user ? { ...options.reporter, ...reporterOf(context.user) } : options.reporter,
|
|
23
|
+
});
|
|
24
|
+
this.widget = widget;
|
|
25
|
+
this.userId = context.user?.id ?? null;
|
|
26
|
+
// On the server there is no page to put a widget on; the door is there and does nothing.
|
|
27
|
+
if (context.browser && autoStart !== false)
|
|
28
|
+
widget.start();
|
|
29
|
+
return widget;
|
|
30
|
+
}
|
|
31
|
+
identify(user) {
|
|
32
|
+
// The widget adds what it is told to what it knows, which is right for one person learning more
|
|
33
|
+
// about themselves and wrong for another person signing in: they would keep the last one's email.
|
|
34
|
+
if (this.userId !== null && this.userId !== user.id)
|
|
35
|
+
this.widget?.identify(null);
|
|
36
|
+
this.userId = user.id;
|
|
37
|
+
this.widget?.identify(reporterOf(user));
|
|
38
|
+
}
|
|
39
|
+
reset() {
|
|
40
|
+
this.userId = null;
|
|
41
|
+
this.widget?.identify(null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The site's user as the reporter a report carries: their id is the widget's `externalId`. */
|
|
45
|
+
function reporterOf(user) {
|
|
46
|
+
const reporter = { externalId: user.id };
|
|
47
|
+
if (user.email)
|
|
48
|
+
reporter.email = user.email;
|
|
49
|
+
if (user.name)
|
|
50
|
+
reporter.name = user.name;
|
|
51
|
+
return reporter;
|
|
52
|
+
}
|
|
53
|
+
registerModule('feedback', () => new FeedbackModule());
|
package/dist/redact.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export declare function describeElement(element: Element): string;
|
|
|
23
23
|
/**
|
|
24
24
|
* Console and error text can contain interpolated user data. Long numeric runs, anything that looks
|
|
25
25
|
* like an email, and bearer tokens are the three that show up in practice.
|
|
26
|
+
*
|
|
27
|
+
* Then every credential secrets.ts recognises on the page (PM-T-0682): a request logged with its
|
|
28
|
+
* api_key, a GitHub token in an error message. Read a little past the cap, so a key the cap would cut
|
|
29
|
+
* in half is still whole when it is looked for.
|
|
26
30
|
*/
|
|
27
31
|
export declare function redactText(text: string): string;
|
|
28
32
|
/** Selector for elements the host app has marked as never-capture. */
|