@siteping/widget 0.9.8 → 0.9.9
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/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -3297,7 +3297,7 @@ ${o.stack}`:""}`;try{let s=new WeakSet;return JSON.stringify(o,(n,a)=>{if(typeof
|
|
|
3297
3297
|
pointer-events:none;
|
|
3298
3298
|
top:-6px;
|
|
3299
3299
|
left:${f}px;
|
|
3300
|
-
`;}contains(s){return this.root.contains(s)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var Qt=null;function mg(o){return o===void 0||o===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:o===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:o.console!==false,network:o.network!==false,maxConsoleEntries:typeof o.maxConsoleEntries=="number"?o.maxConsoleEntries:50,maxNetworkEntries:typeof o.maxNetworkEntries=="number"?o.maxNetworkEntries:20}}function Jr(){let o=()=>{};return {destroy:o,open:o,close:o,refresh:o,on:()=>o,off:o}}function Na(o){let s=o.debug?(...V)=>console.debug("[siteping]",...V):()=>{};if(Qt)return s("initSiteping() called more than once \u2014 returning existing instance"),Qt;if(!o.forceShow)try{if(typeof process<"u")return o.onSkip?.("production"),Jr()}catch{}if(window.innerWidth<768){let V="mobile";return o.onSkip?.(V),Jr()}if(!o.store&&(!o.endpoint||typeof o.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),Jr();if(!o.projectName||typeof o.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),Jr();let n=o.locale??"en";n!=="en"&&la(n).catch(()=>{});let a=Lr(n),c=o.scopeAnnotationsByUrl??true,p=()=>{try{let V=o.getPageScope?.();if(V)return V}catch(V){s("getPageScope() threw, falling back to pathname:",V);}return {url:window.location.pathname,urlPattern:null}};s("Initializing widget",{projectName:o.projectName,theme:o.theme??"light",locale:n,scopeAnnotationsByUrl:c});let g=mg(o.captureDiagnostics),f=g.console?new Hr(g.maxConsoleEntries):null,m=g.network?new Ir(g.maxNetworkEntries):null,Q=Oo(o.accentColor,o.theme),b=new wt,F=new wt,I=o.store?new Mr(o.store,o.projectName):new Er(o.endpoint,o.projectName);o.onOpen&&b.on("open",o.onOpen),o.onClose&&b.on("close",o.onClose),o.onFeedbackSent&&b.on("feedback:sent",o.onFeedbackSent),o.onError&&b.on("feedback:error",o.onError),o.onAnnotationStart&&b.on("annotation:start",o.onAnnotationStart),o.onAnnotationEnd&&b.on("annotation:end",o.onAnnotationEnd),b.on("feedback:sent",V=>F.emit("feedback:sent",V)),b.on("feedback:deleted",V=>F.emit("feedback:deleted",V)),b.on("open",()=>F.emit("panel:open")),b.on("close",()=>F.emit("panel:close")),b.on("open",()=>s("Panel opened")),b.on("close",()=>s("Panel closed")),b.on("feedback:sent",V=>s("Feedback sent",V.id)),b.on("feedback:error",V=>s("Feedback failed",V.message)),b.on("annotation:start",()=>s("Annotation started")),b.on("annotation:end",()=>s("Annotation ended"));let M=document.createElement("siteping-widget");M.style.cssText=`position:fixed;z-index:${2147483647};`;let O=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(O=!0);}catch{}let N=O?"open":"closed",P=M.attachShadow({mode:N});if("adoptedStyleSheets"in ShadowRoot.prototype){let V=new CSSStyleSheet;V.replaceSync(wn(Q)),P.adoptedStyleSheets=[V];}else {let V=document.createElement("style");V.textContent=wn(Q),P.appendChild(V);}document.body.appendChild(M);let E=document.createElement("div");E.setAttribute("role","status"),E.setAttribute("aria-live","polite"),E.setAttribute("aria-atomic","true"),E.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(E);let G=new Yr(Q,n),R=new Dr(Q,G,b,a,E),$=new kr(P,o,b,a),j=null,lA=null,rA=false;async function BA(){return rA?null:j||(lA||(lA=Promise.resolve().then(()=>(Oa(),Ra)).then(V=>rA?null:(j=new V.Panel(P,Q,b,I,o.projectName,R,a,n,{getScope:p,scopeAnnotationsByUrl:c}),j))),lA)}if(typeof window<"u"){let V=()=>{rA||BA();},uA=window.requestIdleCallback;typeof uA=="function"?uA(V):setTimeout(V,200);}let oA=false,ve=b.on("panel:toggle",V=>{j||(V?(oA=true,BA().then(uA=>{uA&&oA&&uA.open(),oA=false;}).catch(uA=>s("Failed to lazy-load panel:",uA))):oA=false);}),Wr=new xr(Q,b,a,o.enableScreenshot??false),Oe=false,jr=b.on("annotation:complete",async V=>{if(!Oe){Oe=true;try{let{annotation:uA,type:PA,message:Ne,screenshotDataUrl:Pe}=V,jA=da();if(!jA){if(jA=await bg(P,a),!jA)return;pa(jA);}let Ft=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),Ge=p(),le=null;(f||m)&&(le={console:f?.getEntries()??[],network:m?.getEntries()??[]});let zr={projectName:o.projectName,type:PA,message:Ne,url:Ge.url,urlPattern:Ge.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:jA.name,authorEmail:jA.email,annotations:[uA],clientId:Ft,screenshotDataUrl:Pe??null,diagnostics:le};try{let DA=await I.sendFeedback(zr);b.emit("feedback:sent",DA),(!c||DA.url===Ge.url)&&R.addFeedback(DA,R.count+1),E.textContent=a("feedback.sent.confirmation"),j&&await j.refresh();}catch(DA){b.emit("feedback:error",DA instanceof Error?DA:new Error(String(DA))),E.textContent=a("feedback.error.message");}}finally{Oe=false;}}}),yt=p(),$r=c?{limit:20,url:yt.url}:{limit:20};return I.getFeedbacks(o.projectName,$r).then(({feedbacks:V})=>{let uA=c?V.filter(PA=>PA.url===yt.url):V;R.render(uA);}).catch(V=>{s("Failed to load initial markers:",V);}),o.endpoint&&Xo(o.endpoint).then(()=>s("Retry queue flushed")).catch(()=>{}),Qt={destroy:()=>{s("Destroying widget"),rA=true,oA=false,jr(),ve(),$.destroy(),j?.destroy(),Wr.destroy(),R.destroy(),G.destroy(),f?.dispose(),m?.dispose(),b.removeAll(),F.removeAll(),E.remove(),M.remove(),Qt=null;},open:()=>{b.emit("panel:toggle",true);},close:()=>{j?j.close():oA=false;},refresh:()=>{if(j?.isCurrentlyOpen){j.refresh();return}let V=p(),uA=c?{limit:20,url:V.url}:{limit:20};I.getFeedbacks(o.projectName,uA).then(({feedbacks:PA})=>{let Ne=c?PA.filter(Pe=>Pe.url===V.url):PA;R.render(Ne);}).catch(()=>{});},on:(V,uA)=>F.on(V,uA),off:(V,uA)=>{F.off(V,uA);}},Qt}function bg(o,s){return new Promise(n=>{let a=o.activeElement??document.activeElement,c=document.createElement("div");c.style.cssText=`
|
|
3300
|
+
`;}contains(s){return this.root.contains(s)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var Qt=null;function mg(o){return o===void 0||o===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:o===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:o.console!==false,network:o.network!==false,maxConsoleEntries:typeof o.maxConsoleEntries=="number"?o.maxConsoleEntries:50,maxNetworkEntries:typeof o.maxNetworkEntries=="number"?o.maxNetworkEntries:20}}function Jr(){let o=()=>{};return {destroy:o,open:o,close:o,refresh:o,on:()=>o,off:o}}function Na(o){let s=o.debug?(...V)=>console.debug("[siteping]",...V):()=>{};if(Qt)return s("initSiteping() called more than once \u2014 returning existing instance"),Qt;if(!o.forceShow)try{if(typeof process<"u")return o.onSkip?.("production"),Jr()}catch{}if(window.innerWidth<768){let V="mobile";return o.onSkip?.(V),Jr()}if(!o.store&&(!o.endpoint||typeof o.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),Jr();if(!o.projectName||typeof o.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),Jr();let n=o.locale??"en";n!=="en"&&la(n).catch(()=>{});let a=Lr(n),c=o.scopeAnnotationsByUrl??true,p=()=>{try{let V=o.getPageScope?.();if(V)return V}catch(V){s("getPageScope() threw, falling back to pathname:",V);}return {url:window.location.pathname,urlPattern:null}};s("Initializing widget",{projectName:o.projectName,theme:o.theme??"light",locale:n,scopeAnnotationsByUrl:c});let g=mg(o.captureDiagnostics),f=g.console?new Hr(g.maxConsoleEntries):null,m=g.network?new Ir(g.maxNetworkEntries):null,Q=Oo(o.accentColor,o.theme),b=new wt,F=new wt,I=o.store?new Mr(o.store,o.projectName):new Er(o.endpoint,o.projectName);o.onOpen&&b.on("open",o.onOpen),o.onClose&&b.on("close",o.onClose),o.onFeedbackSent&&b.on("feedback:sent",o.onFeedbackSent),o.onError&&b.on("feedback:error",o.onError),o.onAnnotationStart&&b.on("annotation:start",o.onAnnotationStart),o.onAnnotationEnd&&b.on("annotation:end",o.onAnnotationEnd),b.on("feedback:sent",V=>F.emit("feedback:sent",V)),b.on("feedback:deleted",V=>F.emit("feedback:deleted",V)),b.on("open",()=>F.emit("panel:open")),b.on("close",()=>F.emit("panel:close")),b.on("open",()=>s("Panel opened")),b.on("close",()=>s("Panel closed")),b.on("feedback:sent",V=>s("Feedback sent",V.id)),b.on("feedback:error",V=>s("Feedback failed",V.message)),b.on("annotation:start",()=>s("Annotation started")),b.on("annotation:end",()=>s("Annotation ended"));let M=document.createElement("siteping-widget");M.style.cssText=`position:fixed;z-index:${2147483647};`;let O=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(O=!0);}catch{}let N=O?"open":"closed",P=M.attachShadow({mode:N});if("adoptedStyleSheets"in ShadowRoot.prototype){let V=new CSSStyleSheet;V.replaceSync(wn(Q)),P.adoptedStyleSheets=[V];}else {let V=document.createElement("style");V.textContent=wn(Q),P.appendChild(V);}document.body.appendChild(M);let E=document.createElement("div");E.setAttribute("role","status"),E.setAttribute("aria-live","polite"),E.setAttribute("aria-atomic","true"),E.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(E);let G=new Yr(Q,n),R=new Dr(Q,G,b,a,E),$=new kr(P,o,b,a),j=null,lA=null,rA=false;async function BA(){return rA?null:j||(lA||(lA=Promise.resolve().then(()=>(Oa(),Ra)).then(V=>rA?null:(j=new V.Panel(P,Q,b,I,o.projectName,R,a,n,{getScope:p,scopeAnnotationsByUrl:c}),j))),lA)}if(typeof window<"u"){let V=()=>{rA||BA();},uA=window.requestIdleCallback;typeof uA=="function"?uA(V):setTimeout(V,200);}let oA=false,ve=b.on("panel:toggle",V=>{j||(V?(oA=true,BA().then(uA=>{uA&&oA&&uA.open(),oA=false;}).catch(uA=>s("Failed to lazy-load panel:",uA))):oA=false);}),Wr=new xr(Q,b,a,o.enableScreenshot??false),Oe=false,jr=b.on("annotation:complete",async V=>{if(!Oe){Oe=true;try{let{annotation:uA,type:PA,message:Ne,screenshotDataUrl:Pe}=V,jA=o.identity??da();if(!jA){if(jA=await bg(P,a),!jA)return;pa(jA);}let Ft=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),Ge=p(),le=null;(f||m)&&(le={console:f?.getEntries()??[],network:m?.getEntries()??[]});let zr={projectName:o.projectName,type:PA,message:Ne,url:Ge.url,urlPattern:Ge.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:jA.name,authorEmail:jA.email,annotations:[uA],clientId:Ft,screenshotDataUrl:Pe??null,diagnostics:le};try{let DA=await I.sendFeedback(zr);b.emit("feedback:sent",DA),(!c||DA.url===Ge.url)&&R.addFeedback(DA,R.count+1),E.textContent=a("feedback.sent.confirmation"),j&&await j.refresh();}catch(DA){b.emit("feedback:error",DA instanceof Error?DA:new Error(String(DA))),E.textContent=a("feedback.error.message");}}finally{Oe=false;}}}),yt=p(),$r=c?{limit:20,url:yt.url}:{limit:20};return I.getFeedbacks(o.projectName,$r).then(({feedbacks:V})=>{let uA=c?V.filter(PA=>PA.url===yt.url):V;R.render(uA);}).catch(V=>{s("Failed to load initial markers:",V);}),o.endpoint&&Xo(o.endpoint).then(()=>s("Retry queue flushed")).catch(()=>{}),Qt={destroy:()=>{s("Destroying widget"),rA=true,oA=false,jr(),ve(),$.destroy(),j?.destroy(),Wr.destroy(),R.destroy(),G.destroy(),f?.dispose(),m?.dispose(),b.removeAll(),F.removeAll(),E.remove(),M.remove(),Qt=null;},open:()=>{b.emit("panel:toggle",true);},close:()=>{j?j.close():oA=false;},refresh:()=>{if(j?.isCurrentlyOpen){j.refresh();return}let V=p(),uA=c?{limit:20,url:V.url}:{limit:20};I.getFeedbacks(o.projectName,uA).then(({feedbacks:PA})=>{let Ne=c?PA.filter(Pe=>Pe.url===V.url):PA;R.render(Ne);}).catch(()=>{});},on:(V,uA)=>F.on(V,uA),off:(V,uA)=>{F.off(V,uA);}},Qt}function bg(o,s){return new Promise(n=>{let a=o.activeElement??document.activeElement,c=document.createElement("div");c.style.cssText=`
|
|
3301
3301
|
position:fixed;inset:0;
|
|
3302
3302
|
background:var(--sp-identity-overlay);
|
|
3303
3303
|
backdrop-filter:blur(8px);
|